[9102] | 1 | ///
|
---|
| 2 | /// This file is part of ILNumerics Community Edition.
|
---|
| 3 | ///
|
---|
| 4 | /// ILNumerics Community Edition - high performance computing for applications.
|
---|
| 5 | /// Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
|
---|
| 6 | ///
|
---|
| 7 | /// ILNumerics Community Edition is free software: you can redistribute it and/or modify
|
---|
| 8 | /// it under the terms of the GNU General Public License version 3 as published by
|
---|
| 9 | /// the Free Software Foundation.
|
---|
| 10 | ///
|
---|
| 11 | /// ILNumerics Community Edition is distributed in the hope that it will be useful,
|
---|
| 12 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | /// GNU General Public License for more details.
|
---|
| 15 | ///
|
---|
| 16 | /// You should have received a copy of the GNU General Public License
|
---|
| 17 | /// along with ILNumerics Community Edition. See the file License.txt in the root
|
---|
| 18 | /// of your distribution package. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | ///
|
---|
| 20 | /// In addition this software uses the following components and/or licenses:
|
---|
| 21 | ///
|
---|
| 22 | /// =================================================================================
|
---|
| 23 | /// The Open Toolkit Library License
|
---|
| 24 | ///
|
---|
| 25 | /// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
---|
| 26 | ///
|
---|
| 27 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
| 28 | /// of this software and associated documentation files (the "Software"), to deal
|
---|
| 29 | /// in the Software without restriction, including without limitation the rights to
|
---|
| 30 | /// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
---|
| 31 | /// the Software, and to permit persons to whom the Software is furnished to do
|
---|
| 32 | /// so, subject to the following conditions:
|
---|
| 33 | ///
|
---|
| 34 | /// The above copyright notice and this permission notice shall be included in all
|
---|
| 35 | /// copies or substantial portions of the Software.
|
---|
| 36 | ///
|
---|
| 37 | /// =================================================================================
|
---|
| 38 | ///
|
---|
| 39 |
|
---|
| 40 | using System;
|
---|
| 41 | using System.Collections;
|
---|
| 42 | using System.Collections.Generic;
|
---|
| 43 | using System.Text;
|
---|
| 44 | using System.Drawing;
|
---|
| 45 |
|
---|
| 46 | namespace ILNumerics.Drawing.Labeling {
|
---|
| 47 | /// <summary>
|
---|
| 48 | /// the class collects renderable items which define
|
---|
| 49 | /// the graphical output for a render expression
|
---|
| 50 | /// </summary>
|
---|
| 51 | /// <remarks>ILRenderQueues are semi-immutable. Instances - once created - can only be cleared and
|
---|
| 52 | /// re-created, but not altered. Therefore, they keep the size of the output cached over their livetime.</remarks>
|
---|
| 53 | public class ILRenderQueue : IEnumerable {
|
---|
| 54 |
|
---|
| 55 | #region attributes
|
---|
| 56 | Size m_size;
|
---|
| 57 | List<ILRenderQueueItem> m_list;
|
---|
| 58 | String m_expression;
|
---|
| 59 | #endregion
|
---|
| 60 |
|
---|
| 61 | #region constructor
|
---|
| 62 | /// <summary>
|
---|
| 63 | /// constructor, creates a new render queue with content
|
---|
| 64 | /// </summary>
|
---|
| 65 | /// <param name="expression">expression, which led to this queue</param>
|
---|
| 66 | /// <param name="queue">prepared queue</param>
|
---|
| 67 | /// <param name="size">size of content after rendering</param>
|
---|
| 68 | public ILRenderQueue(string expression, List<ILRenderQueueItem> queue, Size size) : base () {
|
---|
| 69 | m_size = size;
|
---|
| 70 | m_list = queue;
|
---|
| 71 | m_expression = expression;
|
---|
| 72 | }
|
---|
| 73 | #endregion
|
---|
| 74 |
|
---|
| 75 | #region properties
|
---|
| 76 | /// <summary>
|
---|
| 77 | /// overall size of content of this render queue
|
---|
| 78 | /// </summary>
|
---|
| 79 | public Size Size {
|
---|
| 80 | get {
|
---|
| 81 | return m_size;
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | /// <summary>
|
---|
| 86 | /// Expression which led to this queue
|
---|
| 87 | /// </summary>
|
---|
| 88 | public string Expression {
|
---|
| 89 | get { return m_expression; }
|
---|
| 90 | }
|
---|
| 91 | #endregion
|
---|
| 92 |
|
---|
| 93 | #region IList<ILRenderQueueItem> Member
|
---|
| 94 |
|
---|
| 95 | public int IndexOf(ILRenderQueueItem item) {
|
---|
| 96 | return m_list.IndexOf(item);
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | //public void Insert(int index, ILRenderQueueItem item) {
|
---|
| 100 | // m_list.Insert(index,item);
|
---|
| 101 | //}
|
---|
| 102 |
|
---|
| 103 | //public void RemoveAt(int index) {
|
---|
| 104 | // m_list.RemoveAt(index);
|
---|
| 105 | //}
|
---|
| 106 |
|
---|
| 107 | public ILRenderQueueItem this[int index] {
|
---|
| 108 | get {
|
---|
| 109 | return m_list[index];
|
---|
| 110 | }
|
---|
| 111 | //set {
|
---|
| 112 | // m_list[index] = value;
|
---|
| 113 | //}
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | #endregion
|
---|
| 117 |
|
---|
| 118 | #region ICollection<ILRenderQueueItem> Member
|
---|
| 119 |
|
---|
| 120 | //public void Add(ILRenderQueueItem item) {
|
---|
| 121 | // // todo: implement pooling of render queue item objects!
|
---|
| 122 | // m_list.Add(item);
|
---|
| 123 | //}
|
---|
| 124 |
|
---|
| 125 | public void Clear() {
|
---|
| 126 | // todo: implement pooling of render queue item objects!
|
---|
| 127 | m_list.Clear();
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | public bool Contains(ILRenderQueueItem item) {
|
---|
| 131 | return m_list.Contains(item);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | public void CopyTo(ILRenderQueueItem[] array, int arrayIndex) {
|
---|
| 135 | m_list.CopyTo(array,arrayIndex);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | public int Count {
|
---|
| 139 | get { return m_list.Count; }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | public bool IsReadOnly {
|
---|
| 143 | get { return false; }
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | //public bool Remove(ILRenderQueueItem item) {
|
---|
| 147 | // return m_list.Remove(item);
|
---|
| 148 | //}
|
---|
| 149 |
|
---|
| 150 | #endregion
|
---|
| 151 |
|
---|
| 152 | #region IEnumerable<ILRenderQueueItem> Member
|
---|
| 153 |
|
---|
| 154 | public IEnumerator<ILRenderQueueItem> GetEnumerator() {
|
---|
| 155 | foreach (ILRenderQueueItem item in m_list)
|
---|
| 156 | yield return item;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | #endregion
|
---|
| 160 |
|
---|
| 161 | #region IEnumerable Member
|
---|
| 162 |
|
---|
| 163 | IEnumerator IEnumerable.GetEnumerator() {
|
---|
| 164 | return m_list.GetEnumerator();
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | #endregion
|
---|
| 168 |
|
---|
| 169 | }
|
---|
| 170 | }
|
---|