/// <summary> /// /// </summary> /// <param name="pts"></param> /// <param name="title"></param> /// <param name="source"></param> /// <param name="gType"></param> /// <param name="tag"></param> /// <returns></returns> public int AddNewGraph(DPoint[] pts, string title, string source, GraphType gType, GraphManipulationTag tag) { if (tag == null) { tag = new GraphManipulationTag(); } if (_graphPanel.InvokeRequired) { var d = new AddNewGraphCallback(AddTNewGraph); _graphPanel.Invoke(d, pts, title, source, gType, tag); } else { AddTNewGraph(pts, title, source, gType, tag); } if (_useOffsetTag) { return(_offsetTagValue - 1); } return(AbsoluteGraphTag - 1); }
/// <summary> This changes for each graph script and idx ; eg.: LineGraph1.xml </summary> public string GetImportPath (int idx, GraphType type, bool localFile) { string tp = ""; switch (type) { case GraphType.Line: tp = LinePath; break; case GraphType.Donut: tp = DonutPath; break; case GraphType.World: tp = WorldPath; break; case GraphType.Filled: tp = FilledPath; break; default: break; } var urlPath = tp + idx + ".xml"; string path; if (localFile) { if (Application.isEditor) path = "file://" + Application.dataPath + "/Palomar/" + urlPath; else path = "file://" + Application.dataPath + '/' + urlPath; } else path = urlPath; return path; }
public static void SetPermissions(this FieldType type, GraphType graphType, bool isBuiltInProperty = false) { // The graph type should have the doc type alias set in the meta data so we're accessing it from that var doctypeAlias = graphType.GetMetadata <string>(Constants.Metadata.ContentTypeAlias); type.SetPermissions(doctypeAlias, isBuiltInProperty); }
public static void Graph(GraphType gType, LEDPanel panel, int startX, int startY, int count, bool invertX = false, bool invertY = false) { switch (gType) { case GraphType.Horizontal: HorizontalLines(panel, startX, startY, count, invertX, invertY); break; case GraphType.Vertical: VerticalLines(panel, startX, startY, count, invertX, invertY); break; case GraphType.Square: Square(panel, startX, startY, count, invertX, invertY); break; case GraphType.DiagonalXFrom0: DiagonalLinesByXAxisFrom0(panel, startX, startY, count, invertX, invertY); break; case GraphType.DiagonalX: DiagonalLinesByXAxis(panel, startX, startY, count, invertX, invertY); break; case GraphType.Diamond: Diamond(panel, startX, startY, count, invertX, invertY); break; } }
public ActionResult GraphDescription(string graphType) { GraphDescriptionModel model = new GraphDescriptionModel(); GraphType type = GraphType.Bars; Enum.TryParse <GraphType>(graphType, out type); model.ImageThumbnail = Url.Content("~/Content/Img/" + type.ToString() + "_mini_" + Helpers.CultureHelper.GetCurrentNeutralCulture() + ".png"); model.GraphType = type; switch (type) { case GraphType.Bars: model.Information = Resources.Resources.GraphTypeBarsInformation; model.GraphTypeAsString = Resources.Resources.GraphTypeBarsLabel; break; case GraphType.Candles: model.Information = Resources.Resources.GraphTypeCandlestickInformation; model.GraphTypeAsString = Resources.Resources.GraphTypeCandlestickLabel; break; case GraphType.Linear: model.Information = Resources.Resources.GraphTypeLinearInformation; model.GraphTypeAsString = Resources.Resources.GraphTypeLinearLabel; break; case GraphType.Volume: model.Information = Resources.Resources.GraphTypeVolumeInformation; model.GraphTypeAsString = Resources.Resources.GraphTypeVolumeLabel; break; } return(View(model)); }
public TypeKind KindForInstance(GraphType type) { switch (type) { case EnumerationGraphType _: return(TypeKind.ENUM); case ScalarGraphType _: return(TypeKind.SCALAR); case IObjectGraphType _: return(TypeKind.OBJECT); case IInterfaceGraphType _: return(TypeKind.INTERFACE); case UnionGraphType _: return(TypeKind.UNION); case IInputObjectGraphType _: return(TypeKind.INPUT_OBJECT); case ListGraphType _: return(TypeKind.LIST); case NonNullGraphType _: return(TypeKind.NON_NULL); default: throw new ExecutionError("Unknown kind of type: {0}".ToFormat(type)); } }
public GraphType theType; //图的类型 public ALGraph(int n, int e, GraphType cuType) { VertexNodeCount = n; BordeCount = e; AdjList = new VertexNode[n]; theType = cuType; }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main1(string[] args) { int e; int n; Console.Write("请输入图的类型: 0 为无向图, 1 为有向图 "); GraphType t = (GraphType)(int.Parse(Console.ReadLine())); Console.Write("请输入图的顶点数 : "); e = int.Parse(Console.ReadLine()); Console.Write("请输入图的边数(如果选择无向图,两接点间的边只需输入一次) : "); n = int.Parse(Console.ReadLine()); ALGraph G = new ALGraph(e, n, t); //构建一个有向图结构 (new GraphOperation()).CreateALGraph(G); Console.Write("\n "); //实现深度遍历 (new GraphOperation()).DFSTraverse(G); Console.Write("\n "); //实现广度遍历 (new GraphOperation()).BFSTraverse(G); Console.Write("\n "); //判断图的类型 (new GraphOperation()).NonPreFirstTopSort(G); Console.ReadLine(); }
//////////////////////////////////////////////////////////////////////// /// Func public UndoRedoStackData(UndoRedoWorkType _workType, GraphType _graphType, string _graphUID) { _targetWorkType = _workType; _targetGraphType = _graphType; _targetGraphUID = _graphUID; }
public bool ContainsGraph(string id, GraphType type) { var key = MakeKey(id, type); var db = GetDBOrNull(id); return(db?.Get(key) == "1"); }
public AdjacencySetGraph(int numVertices, GraphType graphType) : base(numVertices, graphType) { for (int i = 0; i < numVertices; i++) { graphNodes.Add(new GraphNode(i)); } }
public Graph(GraphType type, int capacity, bool allowMultigraphs = true) { allowMultiGraph = allowMultigraphs; graphType = type; nodes = new List <Node <TNodeValue, TLinkProperty> >(capacity); links = new List <Link <TNodeValue, TLinkProperty> >(capacity); }
private void ForceMarkersOnPan() { const GraphType gType = GraphType.MoveableMarker; foreach (var t in _graphTabPanel.Cst.MainPan.TagList) { var gs = _graphPanel.GetGraphSurfaceFromTag(t.Tag); if (gs?.GType != gType) { continue; } if (_graphTabPanel.Cst.SubPan == null) { continue; } foreach (var t1 in _graphTabPanel.Cst.SubPan) { if (!_graphParameters.ContextMenu.ResetAsubtag(t1, t.Tag, true)) { _graphParameters.ContextMenu.SetAsubtag(t1, t); } } } }
private FieldType GetFieldDef(ISchema schema, GraphType parentType, Field field) { var name = field.Name; if (name == SchemaIntrospection.SchemaMeta.Name && Equals(schema.Query, parentType)) { return(SchemaIntrospection.SchemaMeta); } if (name == SchemaIntrospection.TypeMeta.Name && Equals(schema.Query, parentType)) { return(SchemaIntrospection.TypeMeta); } if (name == SchemaIntrospection.TypeNameMeta.Name && (parentType is ObjectGraphType || parentType is InterfaceGraphType || parentType is UnionGraphType)) { return(SchemaIntrospection.TypeNameMeta); } if (parentType is ObjectGraphType || parentType is InterfaceGraphType) { return(parentType.Fields.FirstOrDefault(x => x.Name == field.Name)); } return(null); }
public static FieldType AddField <TGraphType>(this GraphType root, string name, string description, FieldResolver resolver = null) where TGraphType : GraphType => root.Field <TGraphType>( name : name, description : description, arguments : resolver?.Arguments, resolve : resolver?.Resolve);
public static PXGraphSemanticModel InferExplicitModel(PXContext pxContext, INamedTypeSymbol typeSymbol, GraphSemanticModelCreationOptions modelCreationOptions, CancellationToken cancellation) { cancellation.ThrowIfCancellationRequested(); pxContext.ThrowOnNull(nameof(pxContext)); typeSymbol.ThrowOnNull(nameof(typeSymbol)); GraphType graphType = GraphType.None; if (typeSymbol.IsPXGraph(pxContext)) { graphType = GraphType.PXGraph; } else if (typeSymbol.IsPXGraphExtension(pxContext)) { graphType = GraphType.PXGraphExtension; } if (graphType != GraphType.None) { return(new PXGraphSemanticModel(pxContext, graphType, typeSymbol, modelCreationOptions, cancellation)); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="Cluster"/> class. /// </summary> /// <param name="parentGraph">The parent graph.</param> public SubGraph(IGraph parentGraph) : base(parentGraph.NodeLookup, parentGraph.EdgeLookup, new SubGraphTracker()) { subGraphType = parentGraph.Type; Name = Guid.NewGuid().ToString("N"); this.parentGraph = parentGraph; }
public IStoreGraph GetGraph(string id, GraphType type) { var db = GetDB(id); string key = MakeKey(id, type); return(new RocksGraph(key, db)); }
public AniGraph() { InitializeComponent(); GraphRenderType = GraphType.Display; TopFrequency = 200000; AnimationInterval = 300; lock (_globalLock) { FillEdgeData(); var rnd = new Random(); _points.Add(new Tuple <PointF[], Color, string>(new PointF[50], Colors.LightSteelBlue, "Test data")); for (var n = 0; n < 50; n++) { _points[0].Item1[n] = new PointF(n, (float)rnd.NextDouble()); } } _aniTimer.Elapsed += AniTimerElapsed; _aniTimer.Start(); IsVisibleChanged += AniGraphIsVisibleChanged; }
public Graph(string filename, GraphType type) { Type = type; Filename = filename; ReadData(filename, type); }
protected void OnDestroy() { SaveNodes(); bcg = null; selectedGraph = 0; graphType = GraphType.None; }
/// <summary> /// Initializes a new instance of the <see cref="ResolveFieldContext"/> class. /// </summary> /// <param name="fieldName">Name of the field.</param> /// <param name="fieldAst">The field ast.</param> /// <param name="fieldDefinition">The field definition.</param> /// <param name="returnType">Type of the return.</param> /// <param name="parentType">Type of the parent.</param> /// <param name="arguments">The arguments.</param> /// <param name="rootValue">The root value.</param> /// <param name="source">The source.</param> /// <param name="schema">The schema.</param> /// <param name="operation">The operation.</param> /// <param name="fragments">The fragments.</param> /// <param name="variables">The variables.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="userContext">The user context.</param> public ResolveFieldContext( string fieldName, Field fieldAst, FieldType fieldDefinition, GraphType returnType, ObjectGraphType parentType, IReadOnlyDictionary<string, object> arguments, object rootValue, object source, ISchema schema, Operation operation, IEnumerable<IFragment> fragments, IEnumerable<Variable> variables, CancellationToken cancellationToken, object userContext) { FieldName = fieldName; FieldAst = fieldAst; FieldDefinition = fieldDefinition; ReturnType = returnType; ParentType = parentType; Arguments = arguments; RootValue = rootValue; Source = source; Schema = schema; Operation = operation; Fragments = fragments; Variables = variables; CancellationToken = cancellationToken; UserContext = userContext; }
public void ReloadChange() { selectedGraph = 0; bcg = null; BocsCyclesNodeManager.Reset(); if (Selection.activeGameObject != null) { bcg = Selection.activeGameObject.GetComponent <BocsCyclesMaterial>(); if (bcg != null) { graphType = GraphType.Material; LoadNodes(); return; } bcg = Selection.activeGameObject.GetComponent <BocsCyclesLight>(); if (bcg != null) { graphType = GraphType.Light; LoadNodes(); return; } bcg = Selection.activeGameObject.GetComponent <BocsCyclesCamera>(); if (bcg != null) { graphType = GraphType.World; LoadNodes(); return; } } }
public Graph(GraphType graphType, DistanceType distanceType) { this.graphType = graphType; this.distanceType = distanceType; nodes = new List <Node>(); edges = new List <Edge>(); }
internal IDictionary <string, object> GetNodes(GraphType graph, Type type, object output) { var result = default(IDictionary <string, object>); var nodesSetter = nodesSetterFactory.Get(type); if (nodesSetter != default) { result = nodesSetter.Invoke( arg1: graph, arg2: output); if (result?.Any() ?? false) { var edgesSetter = edgesSetterFactory.Get(type); if (edgesSetter != default) { edgesSetter.Invoke( arg1: graph, arg2: result, arg3: output); } } } return(result); }
private static void ProcessProperties(GraphType graphType, IEnumerable <PropertyInfo> properties, bool isInputType = false) { foreach (var property in properties.OrderBy(p => p.Name)) { bool isNotNull = TypeHelper.IsNotNull(property); var propertyGraphType = TypeHelper.GetGraphType(property); if (propertyGraphType != null) { propertyGraphType = GraphTypeConverter.ConvertTypeToGraphType(propertyGraphType, isNotNull, isInputType); propertyGraphType = EnsureList(property.PropertyType, propertyGraphType); } else { propertyGraphType = GraphTypeConverter.ConvertTypeToGraphType(property.PropertyType, isNotNull, isInputType); } var name = StringHelper.GraphName(property.Name); var field = graphType.Field( propertyGraphType, name, TypeHelper.GetDescription(property)); field.DefaultValue = TypeHelper.GetDefaultValue(property); field.DeprecationReason = TypeHelper.GetDeprecationReason(property); } }
public void CreateChart(GraphType graphType) { switch (graphType) { case GraphType.Bar: CreateBarChart(); break; } }
public void ReadData(string filename, GraphType type) { try { var lines = File.ReadAllLines(filename); Size = int.Parse(lines[0]); int edgeCount = int.Parse(lines[1]); NewEmptyGraph(Size, type); for (int i = 0; i < edgeCount; i++) { var firstNode = int.Parse(lines[i + 2].Split(' ')[0]); var secondNode = int.Parse(lines[i + 2].Split(' ')[1]); var capacity = int.Parse(lines[i + 2].Split(' ')[2]); AddEdge(firstNode, secondNode, capacity); } } catch (Exception) { Console.WriteLine("Fisierul de date nu este in regula !!"); } }
/// <summary> /// 创建图元结点 /// </summary> /// <param name="graphType">图元类型</param> /// <param name="location">图元位置</param> /// <param name="autoConnect">是否自动连接</param> protected void CreateNode(GraphType graphType, Point location, bool autoConnect) { DocumentManager documentManager = DocumentManager.GetDocumentManager(); FlowChartManager flowChartManager = documentManager.CurrentFlowChartManager; flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(graphType, location, autoConnect); }
public string PrintType(GraphType type) { if (type is EnumerationGraphType) { return(PrintEnum((EnumerationGraphType)type)); } if (type is ScalarGraphType) { return(PrintScalar((ScalarGraphType)type)); } if (type is ObjectGraphType) { return(PrintObject((ObjectGraphType)type)); } if (type is InterfaceGraphType) { return(PrintInterface((InterfaceGraphType)type)); } if (type is UnionGraphType) { return(PrintUnion((UnionGraphType)type)); } if (!(type is InputObjectGraphType)) { throw new InvalidOperationException("Unknown GraphType {0}".ToFormat(type.GetType().Name)); } return(PrintInputObject((InputObjectGraphType)type)); }
public static ITopologyGenerator GetTopologyGenerator(GraphType graphType) { switch (graphType) { case GraphType.Random3: return(new RandomTopologyGenerator(3)); case GraphType.Random6: return(new RandomTopologyGenerator(6)); case GraphType.Random9: return(new RandomTopologyGenerator(9)); case GraphType.Line: return(new LineTopologyGenerator()); case GraphType.Circle: return(new CircleTopologyGenerator()); case GraphType.Star: return(new StarTopologyGenerator()); case GraphType.Bipartite: return(new BipartiteTopologyGenerator()); case GraphType.BinaryTree: return(new BinaryTreeTopologyGenerator()); case GraphType.Complete: return(new CompleteTopologyGenerator()); } return(null); }
public GraphDataModel(string title = "", string yaxis = "", string xaxis = "", GraphType graphType = 0) { Title = title; Yaxis = yaxis; Xaxis = xaxis; gType = graphType; }
private PXGraphSemanticModel(PXContext pxContext, GraphType type, INamedTypeSymbol symbol, GraphSemanticModelCreationOptions modelCreationOptions, CancellationToken cancellation = default) { cancellation.ThrowIfCancellationRequested(); PXContext = pxContext; Type = type; Symbol = symbol; _cancellation = cancellation; ModelCreationOptions = modelCreationOptions; GraphSymbol = Type switch { GraphType.PXGraph => Symbol, GraphType.PXGraphExtension => Symbol.GetGraphFromGraphExtension(PXContext), _ => null, }; StaticConstructors = Symbol.GetStaticConstructors(_cancellation); ViewsByNames = GetDataViews(); ViewDelegatesByNames = GetDataViewDelegates(); ActionsByNames = GetActions(); ActionHandlersByNames = GetActionHandlers(); InitProcessingDelegatesInfo(); Initializers = GetDeclaredInitializers().ToImmutableArray(); IsActiveMethodInfo = GetIsActiveMethodInfo(); }
private HashSet <GraphInfo> BuildPosition(HashSet <long> conIDs) { HashSet <GraphInfo> position = new HashSet <GraphInfo>(); foreach (long ID in conIDs) { GraphInfo contract; if (graphCache.GetGraphInfo(ID, out contract)) { position.Add(contract); } else { GraphBuilder builder = new GraphBuilder(graphCache); ExposureDataAdaptor expData = graphCache.GetExposure(ID); GraphType type = graphCache.GetSettings(ID).GraphType; IRITEindexMapper mapper = GetMapper(expData); contract = builder.MakeGraph(type, expData, mapper); graphCache.Add(ID, contract); position.Add(contract); } } return(position); }
public IGraphCreator GetCaloriesComparisonGraph(GraphType graphType, MyFitnessList MyFitnesses, DataSetBuilder dataSetBuilder, int Days) { int LeftRange; List<int[]> caloriesComparison = dataSetBuilder.CaloriesComparison(out LeftRange); IGraphCreator Graph = new GoogleChartGraphCreator(caloriesComparison, dataSetBuilder.DateLabels, LeftRange); Graph.CreateChart(graphType); return Graph; }
public string BadValueMessage( string argName, GraphType type, string value, IEnumerable<string> verboseErrors) { var message = verboseErrors != null ? $"\n{string.Join("\n", verboseErrors)}" : ""; return $"Argument \"{argName}\" has invalid value {value}.{message}"; }
/// <summary> /// For the field name provided, determine if there are any similar field names /// that may be the result of a typo. /// </summary> private IEnumerable<string> getSuggestedFieldNames( GraphType type, string fieldName) { if (type is ObjectGraphType || type is InterfaceGraphType) { return StringUtils.SuggestionList(fieldName, type.Fields.Select(x => x.Name)); } return Enumerable.Empty<string>(); }
/// <summary> /// if a variable defintion has a default value, it is effectively non-null. /// </summary> private GraphType effectiveType(GraphType varType, VariableDefinition varDef) { if (varDef.DefaultValue == null || varType is NonNullGraphType) { return varType; } var type = varType.GetType(); var genericType = typeof(NonNullGraphType<>).MakeGenericType(type); return (GraphType)Activator.CreateInstance(genericType); }
private string get_str_from_graph_type(GraphType graphtype) { string gt_str = "Error"; if (graphtype == GraphType.DirectedGraph) { gt_str = "digraph"; } else { throw new System.ArgumentOutOfRangeException("graphtype"); } return gt_str; }
private void CollectTypes(GraphType type, GraphTypesLookup lookup) { if (type == null) { return; } lookup[type.ToString()] = type; type.Fields.Apply(field => { CollectTypes(field.Type, lookup); }); }
// TODO: combine dupliation with CoerceValueAST public object CoerceValue(Schema schema, GraphType type, object input) { if (type is NonNullGraphType) { var nonNull = type as NonNullGraphType; return CoerceValue(schema, schema.FindType(nonNull.Type), input); } if (input == null) { return null; } if (type is ListGraphType) { var listType = type as ListGraphType; var list = input as IEnumerable; return list != null ? list.Map(item => CoerceValue(schema, listType, item)) : new[] { input }; } if (type is ObjectGraphType) { var objType = type as ObjectGraphType; var obj = new Dictionary<string, object>(); var dict = (Dictionary<string, object>)input; objType.Fields.Apply(field => { var fieldValue = CoerceValue(schema, schema.FindType(field.Type), dict[field.Name]); obj[field.Name] = fieldValue ?? field.DefaultValue; }); } if (type is ScalarGraphType) { var scalarType = type as ScalarGraphType; return scalarType.Coerce(input); } return null; }
public Graph(GraphType graphType, IList<Tuple<int, int>> connections, int vertices) { if (connections == null) { throw new ArgumentNullException("connections"); } this.vertices = vertices; this.edges = 0; this.adj = new List<IList<int>>(); for (var i = 0; i < vertices; i++) { this.adj.Add(new List<int>()); } if (graphType == GraphType.Undirected) { this.AddUndirectedEdges(connections); } else if (graphType == GraphType.Directed) { this.AddDirectedEdges(connections); } else { var msg = String.Format("Unknown GraphType {0}", graphType); throw new ArgumentException(msg); } }
private void Field(GraphType type, Field field, ValidationContext context) { if (type == null) { return; } if (type.IsLeafType(context.Schema)) { if (field.SelectionSet != null && field.SelectionSet.Selections.Any()) { var error = new ValidationError(context.OriginalQuery, "5.2.3", NoSubselectionAllowedMessage(field.Name, context.Print(type)), field.SelectionSet); context.ReportError(error); } } else if(field.SelectionSet == null || !field.SelectionSet.Selections.Any()) { var error = new ValidationError(context.OriginalQuery, "5.2.3", RequiredSubselectionMessage(field.Name, context.Print(type)), field); context.ReportError(error); } }
public bool IsValidValue(ISchema schema, GraphType type, object input) { if (type is NonNullGraphType) { if (input == null) { return false; } return IsValidValue(schema, schema.FindType(((NonNullGraphType)type).Type), input); } if (input == null) { return true; } if (type is ListGraphType) { var listType = (ListGraphType) type; var listItemType = schema.FindType(listType.Type); var list = input as IEnumerable; return list != null && !(input is string) ? list.All(item => IsValidValue(schema, listItemType, item)) : IsValidValue(schema, listItemType, input); } if (type is ObjectGraphType || type is InputObjectGraphType) { var dict = input as Dictionary<string, object>; if (dict == null) { return false; } // ensure every provided field is defined if (type is InputObjectGraphType && dict.Keys.Any(key => type.Fields.FirstOrDefault(field => field.Name == key) == null)) { return false; } return type.Fields.All(field => IsValidValue(schema, schema.FindType(field.Type), dict.ContainsKey(field.Name) ? dict[field.Name] : null)); } if (type is ScalarGraphType) { var scalar = (ScalarGraphType) type; return scalar.Coerce(input) != null; } return false; }
public async Task<object> CompleteValue(ExecutionContext context, GraphType fieldType, Fields fields, object result) { var nonNullType = fieldType as NonNullGraphType; if (nonNullType != null) { var completed = await CompleteValue(context, context.Schema.FindType(nonNullType.Type), fields, result); if (completed == null) { throw new ExecutionError("Cannot return null for non-null type. Field: {0}".ToFormat(nonNullType.Name)); } return completed; } if (result == null) { return null; } if (fieldType is ScalarGraphType) { var scalarType = fieldType as ScalarGraphType; var coercedValue = scalarType.Coerce(result); return coercedValue; } if (fieldType is ListGraphType) { var list = result as IEnumerable; if (list == null) { throw new ExecutionError("User error: expected an IEnumerable list though did not find one."); } var listType = fieldType as ListGraphType; var itemType = context.Schema.FindType(listType.Type); var results = await list.MapAsync(async item => { return await CompleteValue(context, itemType, fields, item); }); return results; } var objectType = fieldType as ObjectGraphType; if (fieldType is InterfaceGraphType) { var interfaceType = fieldType as InterfaceGraphType; objectType = interfaceType.ResolveType(result); } if (objectType == null) { return null; } var subFields = new Dictionary<string, Fields>(); fields.Apply(field => { subFields = CollectFields(context, objectType, field.Selections, subFields); }); return await ExecuteFields(context, objectType, result, subFields); }
void HandleToggled(object sender, EventArgs args) { RadioButton r = sender as RadioButton; if (r == pieradiobutton && r.Active) { graphType = GraphType.Pie; Reload (); } else if (r == historadiobutton && r.Active) { graphType = GraphType.Histogram; Reload (); } }
public bool DoesFragmentConditionMatch(ExecutionContext context, IHaveFragmentType fragment, GraphType type) { var conditionalType = context.Schema.FindType(fragment.Type); if (conditionalType == type) { return true; } if (conditionalType is InterfaceGraphType) { var interfaceType = (InterfaceGraphType) conditionalType; var hasInterfaces = type as IImplementInterfaces; if (hasInterfaces != null) { var interfaces = context.Schema.FindTypes(hasInterfaces.Interfaces); return interfaceType.IsPossibleType(interfaces); } } return false; }
/// <summary> /// create specific graph type for Direct3D use /// </summary> /// <param name="data">numeric array, shape depends on plot type</param> /// <param name="properties">graph properties</param> /// <param name="additionalParams">additional parameter, currently not used</param> /// <returns>ILGraph object</returns> public override ILGraph CreateGraph(ILBaseArray data, GraphType graphType, params object[] additionalParams) { switch(graphType) { case GraphType.Plot2D: return new ILDXGraphPlot2D(this, data,m_graphs.Clipping); case GraphType.Surf: return new ILDXGraphSurf3D(this, data,m_graphs.Clipping); default: throw new ILInvalidOperationException("Graph type not supported: " + graphType.ToString()); } }
public string PrintType(GraphType type) { if (type is EnumerationGraphType) { return PrintEnum((EnumerationGraphType)type); } if (type is ScalarGraphType) { return PrintScalar((ScalarGraphType)type); } if (type is ObjectGraphType) { return PrintObject((ObjectGraphType)type); } if (type is InterfaceGraphType) { return PrintInterface((InterfaceGraphType)type); } if (type is UnionGraphType) { return PrintUnion((UnionGraphType)type); } if (!(type is InputObjectGraphType)) { throw new InvalidOperationException("Unknown GraphType {0}".ToFormat(type.GetType().Name)); } return PrintInputObject((InputObjectGraphType)type); }
/// <summary> /// 创建显示缩略的图元 /// </summary> /// <param name="graphType">图元的类型</param> /// <param name="point">图元的位置</param> /// <param name="autoConnect">是否自动连接</param> /// <param name="jumpConnect">是否跳转连接</param> public void CreateAbbreviateGraphElement(GraphType graphType, Point p, bool autoConnect) { Point point = Point.Empty; if (!p.IsEmpty) { point = p - new Size(canvas.AutoScrollPosition); } canvas.AbbreviatGraphElement = CreateAbbreviateGraphElement(graphType, point); userOperation = UserOperation.Create; this.autoConnect = autoConnect; if (autoConnect) // 记录当前选中的插槽容器 { lastConnectGraphElement = selectedGraphElement as SlotContainer; // 创建缩略图元的连接线 int tailX = (int)(lastConnectGraphElement.Location.X + lastConnectGraphElement.ElementSize.Width / 2); int tailY = (int)(lastConnectGraphElement.Location.Y + lastConnectGraphElement.ElementSize.Height); int headX = (int)(canvas.AbbreviatGraphElement.Location.X + canvas.AbbreviatGraphElement.ElementSize.Width / 2); int headY = (int)(canvas.AbbreviatGraphElement.Location.Y); canvas.AbbreviateLine = new ConnectorContainer(new Point(tailX, tailY), new Point(headX, headY)); canvas.AbbreviateLine.Init(); } else // 清空连接线 { canvas.AbbreviateLine = null; } if (!p.IsEmpty) // 显示提示信息 { InitTooltipText(canvas.AbbreviatGraphElement, "<underline>鼠标拖动移动图元\r\n<underline>鼠标点击创建图元\r\n<underline>按Esc键取消创建图元", point); } RefreshCanvas(); }
/// <summary> /// 创建缩略的图元 /// </summary> /// <param name="graphType">图元类型</param> /// <param name="centerLocation">图元中心位置</param> /// <param name="elementSize">图元大小</param> /// <param name="moveSize">图元的移动大小</param> /// <returns>图元对象</returns> private GraphElement CreateAbbreviateGraphElement(GraphType graphType, Point centerLocation) { GraphElement abbreviateGraphElement = null; switch (graphType) { case GraphType.ConditionNode: // 条件结点 { abbreviateGraphElement = new ConditionGraphElement(centerLocation - graphSetting.ConditionNodeMoveOffset, graphSetting.ConditionNodeElementSize); moveOffset = graphSetting.ConditionNodeMoveOffset; break; } case GraphType.ActionNode: // 动作结点 { abbreviateGraphElement = new ActionGraphElement(centerLocation - graphSetting.ActionNodeMoveOffset, graphSetting.ActionNodeElementSize); moveOffset = graphSetting.ActionNodeMoveOffset; break; } case GraphType.EventNode: // 事件结点 { abbreviateGraphElement = new EventGraphElement(centerLocation - graphSetting.EventNodeMoveOffset, graphSetting.EventNodeElementSize); moveOffset = graphSetting.EventNodeMoveOffset; break; } case GraphType.AIStateNode: // AI状态结点 { abbreviateGraphElement = new AIStateGraphElement(centerLocation - graphSetting.AIStateNodeMoveOffset, graphSetting.AIStateNodeElementSize); moveOffset = graphSetting.AIStateNodeMoveOffset; break; } case GraphType.AIActionNode: // AI动作结点 { abbreviateGraphElement = new AIActionGraphElement(centerLocation - graphSetting.AIActionNodeMoveOffset, graphSetting.AIActionsNodeElementSize); moveOffset = graphSetting.AIActionNodeMoveOffset; break; } case GraphType.AIActionsNode: // AI动作组结点 { abbreviateGraphElement = new AIActionsGraphElement(centerLocation - graphSetting.AIActionsNodeMoveOffset, graphSetting.AIActionsNodeElementSize); moveOffset = graphSetting.AIActionsNodeMoveOffset; break; } case GraphType.InnerChart: // 子绘图结点 { abbreviateGraphElement = new InnerChart(centerLocation - graphSetting.InnerChartMoveOffset, graphSetting.InnerChartElementSize); moveOffset = graphSetting.InnerChartMoveOffset; break; } case GraphType.InterfaceNode: // 接口结点 { abbreviateGraphElement = new InterfaceGraphElement(centerLocation - graphSetting.InterfaceNodeMoveOffset, graphSetting.InterfaceNodeElementSize); moveOffset = graphSetting.InterfaceNodeMoveOffset; break; } } if (abbreviateGraphElement != null) { abbreviateGraphElement.Refresh(); } return abbreviateGraphElement; }
public TypeKind KindForInstance(GraphType type) { if (type is EnumerationGraphType) { return TypeKind.ENUM; } if (type is ScalarGraphType) { return TypeKind.SCALAR; } if (type is ObjectGraphType) { return TypeKind.OBJECT; } if (type is InterfaceGraphType) { return TypeKind.INTERFACE; } if (type is UnionGraphType) { return TypeKind.UNION; } if (type is InputObjectGraphType) { return TypeKind.INPUT_OBJECT; } if (type is ListGraphType) { return TypeKind.LIST; } if (type is NonNullGraphType) { return TypeKind.NON_NULL; } throw new ExecutionError("Unkown kind of type: {0}".ToFormat(type)); }
public string ResolveName(GraphType type) { if (type is NonNullGraphType) { var nullable = (NonNullGraphType)type; return "{0}!".ToFormat(ResolveName(Schema.FindType(nullable.Type))); } if (type is ListGraphType) { var list = (ListGraphType)type; return "[{0}]".ToFormat(ResolveName(Schema.FindType(list.Type))); } return type.Name; }
public object CoerceValue(ISchema schema, GraphType type, object input, Variables variables = null) { if (type is NonNullGraphType) { var nonNull = type as NonNullGraphType; return CoerceValue(schema, schema.FindType(nonNull.Type), input, variables); } if (input == null) { return null; } var variable = input as Variable; if (variable != null) { return variables != null ? variables.ValueFor(variable.Name) : null; } if (type is ListGraphType) { var listType = type as ListGraphType; var listItemType = schema.FindType(listType.Type); var list = input as IEnumerable; return list != null && !(input is string) ? list.Map(item => CoerceValue(schema, listItemType, item, variables)).ToArray() : new[] { CoerceValue(schema, listItemType, input, variables) }; } if (type is ObjectGraphType || type is InputObjectGraphType) { var obj = new Dictionary<string, object>(); if (input is KeyValuePair<string, object>) { var kvp = (KeyValuePair<string, object>)input; input = new Dictionary<string, object> { { kvp.Key, kvp.Value } }; } var kvps = input as IEnumerable<KeyValuePair<string, object>>; if (kvps != null) { input = kvps.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); } var dict = input as Dictionary<string, object>; if (dict == null) { return null; } type.Fields.Apply(field => { object inputValue; if (dict.TryGetValue(field.Name, out inputValue)) { var fieldValue = CoerceValue(schema, schema.FindType(field.Type), inputValue, variables); obj[field.Name] = fieldValue ?? field.DefaultValue; } }); return obj; } if (type is ScalarGraphType) { var scalarType = type as ScalarGraphType; return scalarType.Coerce(input); } return input; }
public Dictionary<string, Fields> CollectFields(ExecutionContext context, GraphType type, Selections selections, Dictionary<string, Fields> fields) { if (fields == null) { fields = new Dictionary<string, Fields>(); } selections.Apply(selection => { if (selection.Field != null) { if (!ShouldIncludeNode(context, selection.Field.Directives)) { return; } var name = selection.Field.Alias ?? selection.Field.Name; if (!fields.ContainsKey(name)) { fields[name] = new Fields(); } fields[name].Add(selection.Field); } else if (selection.Fragment != null) { if (selection.Fragment is FragmentSpread) { var spread = selection.Fragment as FragmentSpread; if (!ShouldIncludeNode(context, spread.Directives)) { return; } var fragment = context.Fragments.FindDefinition(spread.Name); if (!ShouldIncludeNode(context, fragment.Directives) || !DoesFragmentConditionMatch(context, fragment, type)) { return; } CollectFields(context, type, fragment.Selections, fields); } else if (selection.Fragment is InlineFragment) { var inline = selection.Fragment as InlineFragment; if (!ShouldIncludeNode(context, inline.Directives) || !DoesFragmentConditionMatch(context, inline, type)) { return; } CollectFields(context, type, inline.Selections, fields); } } }); return fields; }
public DataSet(ConfigNode node, RasterPropMonitorComputer rpmComp) { Vector4 packedPosition = ConfigNode.ParseVector4(node.GetValue("borderPosition")); position.x = packedPosition.x; position.y = packedPosition.y; size.x = packedPosition.z; size.y = packedPosition.w; if (node.HasValue("borderColor")) { color = ConfigNode.ParseColor32(node.GetValue("borderColor")); } if (node.HasValue("borderWidth")) { lineWidth = int.Parse(node.GetValue("borderWidth")); } string graphTypeStr = node.GetValue("graphType").Trim(); if (graphTypeStr == GraphType.VerticalUp.ToString()) { graphType = GraphType.VerticalUp; } else if (graphTypeStr == GraphType.VerticalDown.ToString()) { graphType = GraphType.VerticalDown; } else if (graphTypeStr == GraphType.VerticalSplit.ToString()) { graphType = GraphType.VerticalSplit; } else if (graphTypeStr == GraphType.HorizontalRight.ToString()) { graphType = GraphType.HorizontalRight; } else if (graphTypeStr == GraphType.HorizontalLeft.ToString()) { graphType = GraphType.HorizontalLeft; } else if (graphTypeStr == GraphType.HorizontalSplit.ToString()) { graphType = GraphType.HorizontalSplit; } else if (graphTypeStr == GraphType.Lamp.ToString()) { graphType = GraphType.Lamp; } else { throw new ArgumentException("Unknown 'graphType' in DATA_SET"); } if (node.HasValue("passiveColor")) { passiveColor = ConfigNode.ParseColor32(node.GetValue("passiveColor")); } if (node.HasValue("activeColor")) { activeColor = ConfigNode.ParseColor32(node.GetValue("activeColor")); } string[] token = node.GetValue("scale").Split(','); if(token.Length != 2) { throw new ArgumentException("Background scale did not contain two values"); } variable = new VariableOrNumberRange(rpmComp, node.GetValue("variableName").Trim(), token[0].Trim(), token[1].Trim()); if (node.HasValue("reverse")) { if (!bool.TryParse(node.GetValue("reverse"), out reverse)) { throw new ArgumentException("So is 'reverse' true or false?"); } } if (node.HasValue("threshold")) { threshold = ConfigNode.ParseVector2(node.GetValue("threshold")); } if (threshold != Vector2.zero) { thresholdMode = true; float min = Mathf.Min(threshold.x, threshold.y); float max = Mathf.Max(threshold.x, threshold.y); threshold.x = min; threshold.y = max; if (node.HasValue("flashingDelay")) { flashingDelay = float.Parse(node.GetValue("flashingDelay")); flashingDelay = Mathf.Max(flashingDelay, 0.0f); } } fillTopLeftCorner = position + new Vector2((float)lineWidth, (float)lineWidth); fillSize = (size - new Vector2((float)(2 * lineWidth), (float)(2 * lineWidth))); }
public string PrintFields(GraphType type) { var fields = type.Fields .Select(x => new { x.Name, Type = ResolveName(Schema.FindType(x.Type)), Args = PrintArgs(x) }).ToList(); return string.Join(Environment.NewLine, fields.Select(f => " {0}{1}: {2}".ToFormat(f.Name, f.Args, f.Type))); }
/// <summary> /// 创建图元结点 /// </summary> /// <param name="graphType">图元类型</param> /// <param name="location">图元位置</param> /// <param name="autoConnect">是否自动连接</param> protected void CreateNode(GraphType graphType, Point location, bool autoConnect) { DocumentManager documentManager = DocumentManager.GetDocumentManager(); FlowChartManager flowChartManager = documentManager.CurrentFlowChartManager; flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(graphType, location, autoConnect); }
private FieldType GetFieldDef(ISchema schema, GraphType parentType, Field field) { var name = field.Name; if (name == SchemaIntrospection.SchemaMeta.Name && Equals(schema.Query, parentType)) { return SchemaIntrospection.SchemaMeta; } if (name == SchemaIntrospection.TypeMeta.Name && Equals(schema.Query, parentType)) { return SchemaIntrospection.TypeMeta; } if (name == SchemaIntrospection.TypeNameMeta.Name && (parentType is ObjectGraphType || parentType is InterfaceGraphType || parentType is UnionGraphType)) { return SchemaIntrospection.TypeNameMeta; } if (parentType is ObjectGraphType || parentType is InterfaceGraphType) { return parentType.Fields.FirstOrDefault(x => x.Name == field.Name); } return null; }
public bool IsValidValue(Schema schema, GraphType type, object input) { if (type is NonNullGraphType) { if (input == null) { return false; } return IsValidValue(schema, schema.FindType(((NonNullGraphType)type).Type), input); } if (input == null) { return true; } if (type is ListGraphType) { var listType = (ListGraphType) type; var list = input as IEnumerable; return list != null ? list.All(item => IsValidValue(schema, type, item)) : IsValidValue(schema, listType, input); } if (type is ObjectGraphType) { var dict = input as Dictionary<string, object>; return dict != null && type.Fields.All(field => IsValidValue(schema, schema.FindType(field.Type), dict[field.Name])); } if (type is ScalarGraphType) { var scalar = (ScalarGraphType) type; return scalar.Coerce(input) != null; } return false; }