private Button AddColorButton() { var newButton = new Button { FlatStyle = FlatStyle.Flat, Location = new Point(btnAddColor.Location.X, btnAddColor.Location.Y), Margin = btnAddColor.Margin, Size = btnAddColor.Size, BackColor = GraphColors.Skip(GraphColorButtons.Count).FirstOrDefault(), UseVisualStyleBackColor = false }; newButton.Click += new EventHandler(ColorButtonClick); newButton.BackColorChanged += new EventHandler(BackColorChangedEvent); var delta = btnDeleteColor.Location.X - btnAddColor.Location.X; btnAddColor.Location = new Point(btnAddColor.Location.X + delta, btnAddColor.Location.Y); btnDeleteColor.Location = new Point(btnDeleteColor.Location.X + delta, btnDeleteColor.Location.Y); grpGraph.Controls.Add(newButton); GraphColorButtons.Add(newButton); btnAddColor.Visible = !GraphColorButtons.Skip(12).Any(); btnDeleteColor.Visible = GraphColorButtons.Skip(2).Any(); return(newButton); }
public override void Save() { Preferences.Set(Preference.BenchmarksFormLocation, FormLocation); Preferences.Set(Preference.BenchmarksFormSize, FormSize); Preferences.Set(Preference.GraphColors, GraphColors.Select(x => x.GetValue <ValueItem <Color> >().Value).ToList()); Preferences.Save(); }
public static void DoBFS(LinkedList<int>[] graph, int source, out int[] distance) { GraphColors[] colors = new GraphColors[graph.Length]; for(int i = 0; i < colors.Length; i++) colors[i] = GraphColors.White; distance = new int[graph.Length]; colors[source] = GraphColors.Gray; distance[source] = 0; Queue<int> q = new Queue<int>(); q.Enqueue(source); while(q.Count != 0) { int u = q.Dequeue(); LinkedList<int> adj = graph[u]; foreach(int v in adj) { if(colors[v] == GraphColors.White) { colors[v] = GraphColors.Gray; distance[v] = distance[u] + 1; q.Enqueue(v); } } colors[u] = GraphColors.Black; } }
void Start() { xV = GameObject.Find("XV").GetComponent <TextMesh>(); yV = GameObject.Find("YV").GetComponent <TextMesh>(); zV = GameObject.Find("ZV").GetComponent <TextMesh>(); dataPointX = 0; dataPointY = 0; dataPointZ = 0; allPoints = new List <GameObject>(); knnPoints = new List <KeyValuePair <int, GameObject> >(); allPoints.Clear(); knnPoints.Clear(); targets = Dataset.GetDataSetTargets(); numberOfTargets = Dataset.GetNumberOfTargets(targets); graphColors = new GraphColors(); graphColors.SetMinMax(); AdjustBlockSize(); if (UseDefault()) { SetDefaultFeatureRepresentation(); PlotDataDefaultData(); } else { SetChangedFeatureRepresentation(); PlotDataChangedFeatureRepresentation(); } if (Dataset.NewDataPoints.Count > 0) { AdjustBlockSizeNewDP(); List <string> NewDataPointAttributes = new List <string>(Dataset.NewDataPoints[0].Keys); PlotNewDataPoint(NewDataPointAttributes); } }
//========================================================================================= // Update functions // public void AfterLoad() { if (EditTreeColor == null) { EditTreeColor = GraphColors.EditTreeDefault(); } EditTreeColor.Check(GraphColors.EditTreeDefault()); if (FullTreeColor == null) { FullTreeColor = GraphColors.FullTreeDefault(); } FullTreeColor.Check(GraphColors.FullTreeDefault()); if (PartialTreeColor == null) { PartialTreeColor = GraphColors.PartialTreeDefault(); } PartialTreeColor.Check(GraphColors.PartialTreeDefault()); if (NavigatorTreeColor == null) { NavigatorTreeColor = GraphColors.FullTreeDefault(); } NavigatorTreeColor.Check(GraphColors.FullTreeDefault()); if (NavigatorSelectedRectangleBrush == null) { NavigatorSelectedRectangleColor = Color.FromArgb(100, Color.Green); } OneTaxonAllImagesVignetteDisplayParams.AfterLoad(); OneTaxonOneImageVignetteDisplayParams.AfterLoad(); TitleVignetteDisplayParams.AfterLoad(); }
public override void _Draw() { _DrawSystem(); for (int i = 0; i < this.data.Count; i++) { _DrawMetricData(GraphColors.graph(i), this.data[i]); } }
// Start is called before the first frame update void Start() { knnPoints = new List <KeyValuePair <int, GameObject> >(); allPoints = new List <GameObject>(); targets = Dataset.GetDataSetTargets(); numberOfTargets = Dataset.GetNumberOfTargets(targets); graphColors = new GraphColors(); listOfPoints = Dataset.ListOfPoints; toggles = GameObject.Find("MatrixCanvas").GetComponent <FeaturesCheckBox>(); CreatePoints(); }
public SquareViewModel(int number) { if (number >= GraphColors.Values.Length) { Color = GraphColors.Random(number); } else { Color = GraphColors.Values[number]; } Number = number; }
// Start is called before the first frame update void Start() { thingsContainer = transform.Find("ThingsContainer").GetComponent <RectTransform>(); graphWindow = GetComponent <RectTransform>(); attribute = graphWindow.Find("Attribute").GetComponent <RectTransform>(); graphColors = new GraphColors(); instances = new List <GameObject>(); attributes = Dataset.GetDataSetFeatures(); ShowGraph(attributes); }
private void _DrawSystem() { Vector2 size = RectSize; int height = (int)size.y; int width = (int)size.x; int xZeroLane = height; // y lane //DrawLine(new Vector2(marginLeft, 0), new Vector2(marginLeft, xZeroLane), GraphColors.system(), 1); // x lane DrawLine(new Vector2(0, xZeroLane), new Vector2(width, xZeroLane), GraphColors.system(), 1); }
private void DeleteColorButton(bool fromButton) { var delta = btnDeleteColor.Location.X - btnAddColor.Location.X; btnAddColor.Location = new Point(btnAddColor.Location.X - delta, btnAddColor.Location.Y); btnDeleteColor.Location = new Point(btnDeleteColor.Location.X - delta, btnDeleteColor.Location.Y); grpGraph.Controls.Remove(GraphColorButtons.Last()); GraphColorButtons.RemoveAt(GraphColorButtons.Count - 1); if (fromButton) { GraphColors.RemoveAt(GraphColors.Count - 1); } btnAddColor.Visible = !GraphColorButtons.Skip(12).Any(); btnDeleteColor.Visible = GraphColorButtons.Skip(2).Any(); }
public void Run() { GraphColors[] colors = new GraphColors[VertexCount]; for(int i = 0; i < colors.Length; i++) colors[i] = GraphColors.White; _tDiscovery = new int[VertexCount]; _tFinish = new int[VertexCount]; int time = 0; foreach(var u in _graph.Keys) { if(colors[u] == GraphColors.White) Visit(u, _graph, colors, ref time); } }
private void _UpdateLegendY(int maxY) { _UpdateLabel(yLabels[0], maxY); yLabels[0].MarginTop = 0; for (int i = 1; i < legendYLabelCount - 1; i++) { int val = (int)(maxY / legendYLabelCount - 1) * i; _UpdateLabel(yLabels[i], val); } _UpdateLabel(yLabels[legendYLabelCount - 1], 0); // y lane float x = getWidth(); DrawLine(new Vector2(x, 0), new Vector2(x, _projection.getMaxHeight()), GraphColors.system(), 1); }
private void Visit(int u, G graph, GraphColors[] colors, ref int time) { colors[u] = GraphColors.Gray; _tDiscovery[u] = time; time += 1; if(_discoveryHook != null) _discoveryHook(u, _tDiscovery[u]); foreach(var v in graph[u]) { if(colors[v] == GraphColors.White) Visit(v, graph, colors, ref time); } _tFinish[u] = time; time += 1; if(_finishHook != null) _finishHook(u, _tFinish[u]); }
private void BackColorChangedEvent(object sender, EventArgs e) { GraphColors.Clear(); GraphColors.AddRange(GraphColorButtons.Select(b => b.BackColor)); }
public void SetSettings(System.Xml.XmlNode node) { System.Xml.XmlElement element = (System.Xml.XmlElement)node; BackgroundColor = SettingsHelper.ParseColor(element["BackgroundColor"]); BackgroundColor2 = SettingsHelper.ParseColor(element["BackgroundColor2"]); GraphColors.Clear(); // GraphColor and GraphColor2 were the old values used to store the GraphColors. If they exist, add their values to our new list of colors. var GraphColor = SettingsHelper.ParseColor(element["GraphColor"]); if (GraphColor != default(Color)) { GraphColors.Add(GraphColor); } var GraphColor2 = SettingsHelper.ParseColor(element["GraphColor2"]); if (GraphColor2 != default(Color)) { GraphColors.Add(GraphColor2); } // Regular parsing of GraphColors. We can't use a default Parser since it's a list and needs to be comma seperated. if (element[nameof(GraphColors)] != null) { var colorString = element[nameof(GraphColors)].InnerText; if (!string.IsNullOrWhiteSpace(colorString)) { GraphColors.AddRange(colorString.Split(',').Select(x => Color.FromArgb(int.Parse(x, NumberStyles.HexNumber)))); } } // The trigger that occurs when GraphGradientType is Plain fires too early. Redo it! cmbGraphGradientType_SelectedValueChanged(null, null); MinimumValue = SettingsHelper.ParseFloat(element["MinimumValue"]); MaximumValue = SettingsHelper.ParseFloat(element["MaximumValue"]); GraphWidth = SettingsHelper.ParseInt(element["GraphWidth"]); GraphHeight = SettingsHelper.ParseInt(element["GraphHeight"]);; HorizontalMargins = SettingsHelper.ParseInt(element["HorizontalMargins"]);; VerticalMargins = SettingsHelper.ParseInt(element["VerticalMargins"]);; GraphStyle = SettingsHelper.ParseEnum <GraphStyle>(element["GraphStyle"]); BackgroundGradient = SettingsHelper.ParseEnum <GradientType>(element["BackgroundGradient"]); GraphGradient = SettingsHelper.ParseEnum <GraphGradientType>(element["GraphGradient"]); GraphSillyColors = SettingsHelper.ParseBool(element["GraphSillyColors"]); ValueTextPosition = SettingsHelper.ParseEnum <Position>(element["ValueTextPosition"]); DescriptiveTextPosition = SettingsHelper.ParseEnum <Position>(element["DescriptiveTextPosition"]); LocalMax = SettingsHelper.ParseBool(element["LocalMax"]); ProcessName = SettingsHelper.ParseString(element["ProcessName"]); DescriptiveText = SettingsHelper.ParseString(element["DescriptiveText"]); var selectedGame = SettingsHelper.ParseString(element["SelectedGame"]); if (selectedGame != null) { var games = ComboBox_ListOfGames.DataSource as List <string>; if (games != null && games.Contains(selectedGame)) { ComboBox_ListOfGames.SelectedItem = selectedGame; var selectedOption = SettingsHelper.ParseString(element["SelectedGameOption"]); if (selectedOption != null) { var options = ComboBox_GameOption.DataSource as List <string>; if (options != null && options.Contains(selectedOption)) { ComboBox_GameOption.SelectedItem = selectedOption; } } } } txtModule.Text = SettingsHelper.ParseString(element["Module"]); txtBase.Text = SettingsHelper.ParseString(element["Base"]); txtOffsets.Text = SettingsHelper.ParseString(element["Offsets"]); ValueType = SettingsHelper.ParseEnum <MemoryType>(element["ValueType"]); DescriptiveTextColor = SettingsHelper.ParseColor(element["DescriptiveTextColor"]); DescriptiveTextFont = SettingsHelper.GetFontFromElement(element["DescriptiveTextFont"]); DescriptiveTextOverrideColor = SettingsHelper.ParseBool(element["DescriptiveTextOverrideColor"]); DescriptiveTextOverrideFont = SettingsHelper.ParseBool(element["DescriptiveTextOverrideFont"]); ValueTextColor = SettingsHelper.ParseColor(element["ValueTextColor"]); ValueTextFont = SettingsHelper.GetFontFromElement(element["ValueTextFont"]); ValueTextOverrideColor = SettingsHelper.ParseBool(element["ValueTextOverrideColor"]); ValueTextOverrideFont = SettingsHelper.ParseBool(element["ValueTextOverrideFont"]); ValueTextDecimals = SettingsHelper.ParseInt(element["ValueTextDecimals"]); UnitsConversionEnabled = SettingsHelper.ParseBool(element["UnitConversionEnabled"]); UnitsUsed = SettingsHelper.ParseEnum <Units>(element["UnitsUsed"]); MeterInGameUnits = CultureSafeFloatParse(SettingsHelper.ParseString(element["MeterInGameUnits"])); UpdatePointer(null, null); }
public void Display(DirectionalGraphRenderer renderer) { if (renderer.DirectedWindowVM.RegenerateGraphView == false) { return; } DirectedGraphViewModel vm = new DirectedGraphViewModel(); double r = Math.Sqrt(Math.Pow(renderer.GraphControl.ActualHeight, 1.8) + Math.Pow(renderer.GraphControl.ActualWidth, 1.8)) / 20; for (int i = 0; i < renderer.Graph.NodesNr; ++i) { double ratio = (double)(renderer.Graph.NodeOrderInColumn(i)) / (double)(renderer.Graph.NodesInColumn(i) - 1); if (double.IsNaN(ratio) || double.IsInfinity(ratio)) { ratio = 0.0; } double x = r + (renderer.GraphControl.ActualWidth - 2 * r) * (double)(renderer.Graph.Columns[i]) / (double)(renderer.Graph.ColumnsCount()); double y = r + (renderer.GraphControl.ActualHeight - 2 * r) * ratio; Color color = GraphColors.GetColor(renderer.Graph.SkojarzenieKolor[i]); vm.Nodes.Add(new CircleViewModel() { X = x, Y = y, Radius = r, Color = new SolidColorBrush(color), Number = i + 1, NodeNumber = i }); } for (int y = 0; y < renderer.Graph.NodesNr; ++y) { for (int x = 0; x < renderer.Graph.NodesNr; ++x) { if (renderer.Graph.GetConnection(y, x) == false) { continue; } var ratio1 = (double)(renderer.Graph.NodeOrderInColumn(y)) / (double)(renderer.Graph.NodesInColumn(y) - 1); var ratio2 = (double)(renderer.Graph.NodeOrderInColumn(x)) / (double)(renderer.Graph.NodesInColumn(x) - 1); if (double.IsNaN(ratio1) || double.IsInfinity(ratio1)) { ratio1 = 0.0; } if (double.IsNaN(ratio2) || double.IsInfinity(ratio2)) { ratio2 = 0.0; } double x1 = r + (renderer.GraphControl.ActualWidth - 2 * r) * (double)(renderer.Graph.Columns[y]) / (double)(renderer.Graph.ColumnsCount()); double y1 = r + (renderer.GraphControl.ActualHeight - 2 * r) * ratio1; double x2 = r + (renderer.GraphControl.ActualWidth - 2 * r) * (double)(renderer.Graph.Columns[x]) / (double)(renderer.Graph.ColumnsCount()); double y2 = r + (renderer.GraphControl.ActualHeight - 2 * r) * ratio2; int maxFlow = 0; foreach (var flow in renderer.Graph.weights) { if (flow > 2000000) { continue; } if (flow > maxFlow) { maxFlow = flow; } } var abc = (float)renderer.Graph.getWeight(y, x); float flowRatio = ((float)renderer.Graph.getWeight(y, x) / (float)maxFlow); Color flowColor = Colors.Green; if (flowRatio <= 1.1) { flowColor = Color.FromRgb((byte)0, (byte)0, (byte)(flowRatio * 255)); } int thickness = 25; if (flowRatio <= 1.1) { thickness = (int)abc * 2; } LineViewModel lineVM = new LineViewModel() { X1 = x1, Y1 = y1, X2 = x2, Y2 = y2, StartNode = y, EndNode = x, //Color = flowColor, Thickness = thickness }; // vm.Connections.Add(lineVM); maxFlow = 0; foreach (var flow in renderer.Graph.Current) { if (flow > maxFlow) { maxFlow = flow; } } abc = (float)renderer.Graph.GetCurrent(x, y); flowRatio = (abc / (float)maxFlow); flowColor = Colors.Green; if (flowRatio <= 1.1) { flowColor = Color.FromRgb((byte)0, (byte)0, (byte)(155 + flowRatio * 100)); } thickness = 15; if (flowRatio <= 1.1) { thickness = (int)abc * 2; } lineVM = new LineViewModel() { X1 = x1, Y1 = y1, X2 = x2, Y2 = y2, StartNode = y, EndNode = x, Color = flowColor, Hint = string.Format("Flow {0}", abc), Thickness = thickness }; vm.Connections.Add(lineVM); double a = (y2 - y1) / (x2 - x1); double b = y2 / (a * x2); double length = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)); double newLength = length - r / 2; double ratio = newLength / length; double newX = x1 + (x2 - x1) * ratio; double newY = y1 + (y2 - y1) * ratio; TriangleViewModel triangleVm = new TriangleViewModel() { X = newX - 10, Y = newY - 5, Angle = lineVM.Angle * (180.0 / Math.PI) + 90.0 }; vm.Triangles.Add(triangleVm); } } renderer.GraphControl.VM = vm; }