public MinWidth_LayoutQuery Clone(MinWidth_LayoutQuery returnType) { MinWidth_LayoutQuery clone = new MinWidth_LayoutQuery(); clone.CopyFrom(this); return(clone); }
public override LayoutQuery OptimizedUsingExample(SpecificLayout example) { MinWidth_LayoutQuery result = this; if (this.MaxWidth > example.Width) { result = this.Clone((MinWidth_LayoutQuery)null); result.setMaxWidth(example.Width); } return(result); }
public override LayoutQuery OptimizedPastDimensions(LayoutDimensions example) { MinWidth_LayoutQuery result = this; double newWidth = example.Width * 0.9999999999; if (this.MaxWidth > newWidth) { result = this.Clone((MinWidth_LayoutQuery)null); result.setMaxWidth(newWidth); if (!result.Accepts(result.ProposedSolution_ForDebugging)) { result.ProposedSolution_ForDebugging = null; } } return(result); }
// tests that the layout satisfies all of the queries consistently public void DebugCheck(LayoutChoice_Set layout) { int i, j; int maxWidth, maxHeight; maxWidth = 127; maxHeight = 127; LayoutDimensions[,] maxScore_dimensions = new LayoutDimensions[maxWidth, maxHeight]; LayoutDimensions[,] minWidth_dimensions = new LayoutDimensions[maxWidth, maxHeight]; LayoutDimensions[,] minHeight_dimensions = new LayoutDimensions[maxWidth, maxHeight]; for (i = 0; i < maxWidth; i++) { System.Diagnostics.Debug.WriteLine(i.ToString() + " of " + maxWidth.ToString()); for (j = 0; j < maxHeight; j++) { int width = i + 29; int height = j; // find the maximum score of all layouts that fit in these dimensions LayoutQuery maxScoreQuery = new MaxScore_LayoutQuery(width, height, LayoutScore.Minimum, this.visualDefaults.LayoutDefaults); SpecificLayout maxScore_layout = layout.GetBestLayout(maxScoreQuery); maxScore_dimensions[i, j] = maxScore_layout.Dimensions; // find the layout of minimum width having at least this score LayoutQuery minWidthQuery = new MinWidth_LayoutQuery(width, height, maxScore_layout.Score, this.visualDefaults.LayoutDefaults); SpecificLayout minWidth_layout = layout.GetBestLayout(minWidthQuery); if (minWidth_layout != null) { minWidth_dimensions[i, j] = minWidth_layout.Dimensions; } // find the layout of minimum height having at least this score LayoutQuery minHeightQuery = new MinHeight_LayoutQuery(width, height, maxScore_layout.Score, this.visualDefaults.LayoutDefaults); SpecificLayout minHeight_layout = layout.GetBestLayout(minHeightQuery); if (minHeight_layout != null) { minHeight_dimensions[i, j] = minHeight_layout.Dimensions; } if (i > 0) { if (maxScore_dimensions[i, j].Score.CompareTo(maxScore_dimensions[i - 1, j].Score) < 0) { System.Diagnostics.Debug.WriteLine("Error: inconsistency between (" + i.ToString() + ", " + j.ToString() + ") and (" + (i - 1).ToString() + ", " + j.ToString() + ")"); } } if (j > 0) { if (maxScore_dimensions[i, j].Score.CompareTo(maxScore_dimensions[i, j - 1].Score) < 0) { System.Diagnostics.Debug.WriteLine("Error: inconsistency between (" + i.ToString() + ", " + j.ToString() + ") and (" + i.ToString() + ", " + (j - 1).ToString() + ")"); } } if ((width == 0 || height == 0) && maxScore_dimensions[i, j].Score.CompareTo(LayoutScore.Zero) > 0) { System.Diagnostics.Debug.WriteLine("Error: clipping not noticed at (" + i.ToString() + ", " + j.ToString() + ")"); } if (minWidth_dimensions[i, j] == null) { System.Diagnostics.Debug.WriteLine("Error: minWidth query for (" + i.ToString() + ", " + j.ToString() + ") returned null"); minWidthQuery.Debug = true; layout.GetBestLayout(minWidthQuery.Clone()); } if (minHeight_dimensions[i, j] == null) { System.Diagnostics.Debug.WriteLine("Error: minHeight query for (" + i.ToString() + ", " + j.ToString() + ") returned null"); } if (i > 0 && minWidth_dimensions[i, j] != null && minWidth_dimensions[i, j] != null) { if (minWidth_dimensions[i, j].Score.CompareTo(minWidth_dimensions[i - 1, j].Score) == 0) { if (minWidth_dimensions[i, j].Width != minWidth_dimensions[i - 1, j].Width) { System.Diagnostics.Debug.WriteLine("Error: width is wrong in minWidth query between (" + i.ToString() + ", " + j.ToString() + ") and (" + (i - 1).ToString() + ", " + j.ToString() + ")"); } } } if (j > 0 && minHeight_dimensions[i, j] != null && minHeight_dimensions[i, j] != null) { if (minHeight_dimensions[i, j].Score.CompareTo(minHeight_dimensions[i, j - 1].Score) == 0) { if (minHeight_dimensions[i, j].Height != minHeight_dimensions[i, j - 1].Height) { System.Diagnostics.Debug.WriteLine("Error: height is wrong in minHeight query between (" + i.ToString() + ", " + j.ToString() + ") and (" + i.ToString() + ", " + (j - 1).ToString() + ")"); minHeightQuery.Debug = true; layout.GetBestLayout(minHeightQuery.Clone()); } } } } } System.Diagnostics.Debug.WriteLine("done with debugCheck"); /* * System.Diagnostics.Debug.WriteLine("checking minWidth queries"); * for (i = 1; i < maxWidth; i++) * { * for (j = 1; j < maxHeight; j++) * { * if (maxScore_dimensions[i, j].Score.CompareTo(maxScore_dimensions[i - 1, j] < 0)) * System.Diagnostics.Debug.WriteLine("Error: inconsistency between (" + i.ToString() + ", " + j.ToString() + ") and (" + (i - 1).ToString() + ", " + j.ToString()); * if (maxScore_dimensions[i, j].Score.CompareTo(maxScore_dimensions[i, j - 1] < 0)) * System.Diagnostics.Debug.WriteLine("Error: inconsistency between (" + i.ToString() + ", " + j.ToString() + ") and (" + i.ToString() + ", " + (j - 1).ToString()); * } * }*/ }