Systems and methods for managing preparation of graphical elements for presentation
Methods and systems are provided for managing the preparation of graphical elements in computer application programs for presentation. The methods independently identify and measure, and identify and arrange, sets of elements. A computer-readable medium is also provided for facilitating the management of the preparation for presentation of graphical elements in computer application programs.
Latest Microsoft Patents:
This invention pertains generally to the fields of computer software development and operating systems, and, more particularly, to the management of the preparation of graphical elements for presentation.
BACKGROUND OF THE INVENTIONA central feature of modern computer operating systems is the ability to present and manage graphical items on an output device, such as a video monitor or printer. When a graphical item is created within an application, the item is sized and placed appropriately for rendering on the output device. Similarly, when an existing graphical item is modified or removed within an application, the output device must reflect this change appropriately. Existing computer operating systems make use of device drivers to communicate with particular output devices, thus sparing an application developer from the messy details of rendering graphical output on specific output devices. Existing computer operating systems accomplish this by publishing Application Programming Interfaces (“APIs”) to prospective application developers.
Generally, an API is a set of high-level function calls made available to the application developer that are independent from the low-level instructions necessary for any particular device. The operating system, with the aid of device drivers, typically performs any needed translation of the high-level API calls to the low-level device-specific calls.
Nevertheless, although an application developer may not wish to concern himself with implementing how his application's graphical elements are physically displayed or rendered on any particular output devices, the developer may be interested in how those elements are logically laid out and managed. For example, an application developer may wish to develop a graphical user interface that displays its menus or arranges icons in a particular manner. Or a developer may wish to develop an application that arranges and displays multiple graphical elements in a single document in a particular fashion.
Existing software tools known in the art have given application developers some of these abilities. WINDOWS USER, for example, provided an API suited for controlling layout in a user interface scenario. MSHTML, on the other hand, provided an API suited for controlling layout in a document scenario. Trying to use either of these APIs in the other scenario, however, greatly increases the programming complexity while severely limiting performance. Furthermore, existing software tools are often too complex for developers who are not experienced with layout algorithms. Further still, existing software tools perform sub-optimally, such that updating a display layout requires significantly more time than necessary.
Accordingly, new methods and systems are needed to improve the ease with which developers can manage the layout of graphical elements in development environments. Further new methods and systems are needed to improve the performance and efficiency with which a computer application and operating system can manage the layout of graphical elements.
BRIEF SUMMARY OF THE INVENTIONIn satisfaction of this need, embodiments of the present invention provide methods and systems for preparing graphical elements for presentation.
In accordance with one aspect of the invention, a method is provided for managing the preparation of a set of graphical elements for presentation. The method comprises identifying a first subset of the elements where measurement is desirable, identifying a second subset of the elements where arrangement is desirable, executing a first series of operations for measuring the elements comprising the first subset, and executing a second series of operations for arranging the elements comprising the second subset.
In some embodiments, each element in the first subset has associated with it a respective island of elements, and each element in the second subset has associated with it a respective island of elements. In some embodiments, identifying the first subset comprises using a first data structure to represent the first subset of the elements, and wherein identifying the second subset comprises using a second data structure to represent the second subset of the elements. In one version, the first and second data structures are queues.
In some embodiments, the first series of operations comprises identifying a maximal element represented in the first data structure, removing the maximal element's representation in the first data structure, measuring the maximal element, and repeating until the first data structure is empty.
In some embodiments, the second series of operations comprises identifying a maximal element represented in the second data structure, removing the maximal element's representation in the second data structure, arranging the maximal element, and repeating the until the second data structure is empty.
In some embodiments, measuring the maximal element comprises measuring an element from the island associated with the maximal element. In some embodiments, measuring the maximal element comprises determining whether an element from the island associated with the maximal element requires measuring.
In some embodiments, the first series of operations further comprises notifying a parent element of the maximal element that the measurements of the maximal element have changed. In some versions, in response to the notification, a representation of the parent element is placed in the first data structure.
In some embodiments, the number of elements represented in the first data structure cannot exceed a fixed maximum number. In some embodiments, the number of elements represented in the second data structure does not exceed a fixed maximum number.
In some embodiments, the first series of operations further comprises determining that an orphan element represented on the first data structure is not to be measured, and removing from the data structure the representation of the orphan element.
In accordance with another aspect of the invention, a system is provided for managing the preparation of a set of graphical elements for presentation. The system comprises a first data structure representing a first subset of the set of graphical elements requiring measurement, a second data structure representing a second subset of the set of graphical elements requiring arrangement, a first procedure using the first data structure for managing the measuring of elements, and a second procedure using the second data structure for managing the arranging of elements.
In some embodiments, the first procedure comprises the steps of identifying a maximal element represented in the first data structure, removing the maximal element's representation in the first data structure, measuring the maximal element, and repeating the until the first data structure is empty.
In some embodiments, the second procedure comprises the steps of identifying a maximal element represented in the second data structure, removing the maximal element's representation in the second data structure, arranging the maximal element, and repeating until the second data structure is empty.
In some embodiments, measuring the maximal element in the first procedure comprises determining whether an element from an island associated with the maximal element requires measuring, and measuring the element from the island associated with the maximal element if it requires measuring.
In some embodiments, the first procedure further comprises notifying a parent element of the maximal element that the measurements of the maximal element have changed.
In some embodiments, the first procedure further comprises determining that an orphan element represented on the first data structure is not to be measured, and removing from the first data structure the representation of the orphan element.
In accordance with still another aspect of the invention, a computer-readable medium including computer-executable instructions is provided for facilitating managing the preparation of graphical elements for presentation in a system. The computer-executable instructions execute the steps of identifying a first subset of the elements where measurement is desirable, identifying a second subset of the elements where arrangement is desirable, executing a first series of operations for measuring the elements comprising the first subset, and executing a second series of operations for arranging the elements comprising the second subset.
In some embodiments, each element in the first subset has associated with it a respective island of elements, and each element in the second subset has associated with it a respective island of elements.
In some embodiments, identifying the first subset comprises using a first data structure to represent the first subset of the elements, and wherein identifying the second subset comprises using a second data structure to represent the second subset of the elements. In some versions, the first and second data structures are queues.
In some embodiments, the first series of operations comprises identifying a maximal element represented in the first data structure, removing the maximal element's representation in the first data structure, measuring the maximal element, and repeating until the first data structure is empty.
In some embodiments, the second series of operations comprises identifying a maximal element represented in the second data structure, removing the maximal element's representation in the second data structure, arranging the maximal element, and repeating until the second data structure is empty.
In some embodiments, measuring the maximal element in the first series of operations comprises measuring an element from the island associated with the maximal element. In some versions, measuring the maximal element in the first series of operations comprises determining whether an element from the island associated with the maximal element requires measuring.
In some embodiments, the first series of operations further comprises notifying a parent element of the maximal element that the measurements of the maximal element have changed. In some embodiments, the first series of operations further comprises placing a representation of the parent element in the first data structure in response to the notification.
In some embodiments, the first series of operations further comprises determining that an orphan element represented on the first data structure is not to be measured, and removing from the data structure the representation of the orphan element.
BRIEF DESCRIPTION OF THE DRAWINGSWhile the appended claims set forth the features of the present invention with particularity, the invention and its advantages are best understood from the following detailed description taken in conjunction with the accompanying drawings, of which:
FIGS. A1 and A2 illustrate a generic programming interface, in accordance with an embodiment of the invention.
FIGS. B1 and B2 illustrate the factoring of communications between code segments, in accordance with an embodiment of the invention.
FIGS. C1 and C2 illustrate redefinition of a programming interface, in accordance with an embodiment of the invention.
FIGS. D1 and D2 illustrate changing the form of a programming interface due to merger of functionality of code segments, in accordance with an embodiment of the invention.
FIGS. E1 and E2 illustrate breaking communication between code segments into multiple discrete communications, in accordance with an embodiment of the invention.
FIGS. F1 and F2 illustrate the dynamic rewriting of code, in accordance with an embodiment of the invention.
DETAILED DESCRIPTION OF THE INVENTIONThe methods and systems to improve the ease with which developers can manage the layout of graphical elements in development environments and to improve the performance and efficiency with which a computer application and operating system can manage the layout of graphical elements will now be described with respect to preferred embodiments; however, the methods and systems of the present invention are not limited to software development tools and computer operating systems. Moreover, the skilled artisan will readily appreciate that the methods and systems described herein are merely exemplary and that variations can be made without departing from the spirit and scope of the invention.
The present invention will be more completely understood through the following detailed description, which should be read in conjunction with the attached drawings. In this description, like numbers refer to similar elements within various embodiments of the present invention. The invention is illustrated as being implemented in a suitable computing environment. Although not required, the invention will be described in the general context of computer-executable instructions, such as procedures, being executed by a personal computer. Generally, procedures include program modules, routines, functions, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. Moreover, those skilled in the art will appreciate that the invention may be practiced with other computer system configurations, including hand-held devices, multi-processor systems, microprocessor based or programmable consumer electronics, network PCs, minicomputers, mainframe computers, and the like. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote memory storage devices. The term computer system may be used to refer to a system of computers such as may be found in a distributed computing environment.
The invention may be described in the general context of computer-executable instructions, such as procedures or program modules, being executed by a computer. Generally, program modules include procedures, routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in local and/or remote computer storage media including memory storage devices.
With reference to
The computer 110 typically includes a variety of computer readable media. Computer readable media can be any available media that can be accessed by the computer 110 and includes both volatile and nonvolatile media, and removable and non-removable media. By way of example, and not limitation, computer readable media may comprise computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by the computer 110. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. Combinations of the any of the above should also be included within the scope of computer readable media.
The system memory 130 includes computer storage media in the form of volatile and/or nonvolatile memory such as read only memory (ROM) 131 and random access memory (RAM) 132. A basic input/output system 133 (BIOS), containing the basic routines that help to transfer information between elements within computer 110, such as during start-up, is typically stored in ROM 131. RAM 132 typically contains data and/or program modules that are immediately accessible to and/or presently being operated on by processing unit 120. By way of example, and not limitation,
The computer 110 may also include other removable/non-removable, volatile/nonvolatile computer storage media. By way of example only,
The drives and their associated computer storage media, discussed above and illustrated in
The computer 110 may operate in a networked environment using logical connections to one or more remote computers, such as a remote computer 180. The remote computer 180 may be a personal computer, a server, a router, a network PC, a peer device or other common network node, and typically includes many or all of the elements described above relative to the computer 110, although only a memory storage device 181 has been illustrated in
When used in a LAN networking environment, the computer 110 is connected to the LAN 171 through a network interface or adapter 170. When used in a WAN networking environment, the computer 110 typically includes a modem 172 or other means for establishing communications over the WAN 173, such as the Internet. The modem 172, which may be internal or external, may be connected to the system bus 121 via the user input interface 160 or other appropriate mechanism. In a networked environment, program modules depicted relative to the computer 110, or portions thereof, may be stored in the remote memory storage device. By way of example, and not limitation,
The invention is well-suited for layout management systems that represent graphical elements in hierarchical form. An example of a hierarchical form is shown in
In one embodiment of the invention, the MeasureCore procedure 312 and the ArrangeCore procedure 314 are defined by a user of the invention and reside within a computer program application, whereas the other procedures are pre-defined and reside on the operating system 324, and are not changeable by a user. In one embodiment, the OnChildDesiredSizeChanged procedure 326 is pre-defined, but may be overridden by a user. That is, a default OnChildDesiredSizeChanged procedure 326 exists on the operating system 324, but a user is allowed to create a different OnChildDesiredSizeChanged procedure that resides in an application program. Similarly, one embodiment of the invention grants a user power to create alternative procedures that affect high-level functionality, but not low-level functionality, of presentation management. By keeping some procedures fixed while allowing others to be defined by a user, the system remains stable yet customizable.
An embodiment of the invention splits the display preparation process into two distinct phases: a measure phase and an arrange phase. In the measure phase, an element determines its DesiredSize. An element's DesiredSize is the size at which the element wishes to be displayed within available parameters. The available parameters are passed to the element from its parent. An element's DesiredSize is thus typically computed independently from the DesiredSize of its siblings. In the arrange phase, an element determines its ComputedSize. An element's ComputedSize is the size at which the element will be displayed. The ComputedSize is determined based on final size parameters passed to the element from its parent. The measure and arrange phases are controlled by a Layout Manager, which keeps track of elements needing arranging or measuring.
Turning to particular procedures associated with an element in an embodiment of the invention, a general process for the Measure procedure 302 is shown in
A general description of the MeasureCore procedure 312, as used in an embodiment of the invention, is now described with reference to
If the element does have children, their sizes are typically computed recursively at step 509. First, a child's available size, ChildAvailSize, is computed during step 510. The method for computing ChildAvailSize depends on the particular setting in which the invention is used, and the user writes the MeasureCore procedure accordingly. Once ChildAvailSize is computed, during step 512 it is passed into a Measure call for the child. As described previously, the Measure call results in a DesiredSize being stored on the child. At step 514, MeasureCore collects the child's DesiredSize and keeps it with the DesiredSizes of its other children. When all the children's DesiredSizes have been collected (upon completing step 514), MeasureCore computes a size for the element and returns this value as output to the procedure during step 504.
A general description of the Arrange procedure 304, as used in an embodiment of the invention, is now described with reference to
The ArrangeCore procedure 314, as used in an embodiment of the invention, is now described with reference to
If the element does have children, their final sizes are typically computed recursively at step 707 by executing a series of sub-steps. First, at sub-step 708 a child's final size, ChildFinalSize, is computed. The method for computing ChildFinalSize will depend on the particular setting in which the invention is used, and the user may write the ArrangeCore procedure 314 accordingly. Once ChildFinalSize is computed, during sub-step 710 it is passed into a Arrange call for the child. As described previously, the Arrange call results in a ComputedSize being stored on the child. ArrangeCore then takes the child's ComputedSize and uses it during step 712 to set the location at which the child element will be displayed. In one embodiment, the location is stored as the top-left coordinate of a rectangle representing the element. Other embodiments, which allow the element to be represented and displayed in different or arbitrary shapes, potentially use a different system or description to identify the display location of the element in relation to its parent view area.
The following XML example illustrates how the previously described procedures and properties are used to layout a control (“Dock”) which sizes its children (“Label”) to equal width, where the content of each child (a text string) is centered:
Assume the Measure call was issued with AvailSize=300, possibly because the width of the top level window was 300. Dock then calls Measure on each child with a AvailSize value of 300. This in turn recursively invokes MeasureCore on each child with an AvailSize of 300. Each Label returns DesiredSize, possibly using AvailSize as guidance for text wrapping. Note that when computing size, the Label's MeasureCore ignores the fact that the content needs to be centered. It ignores this information because the alignment does not affect the size of the control. The alignment affects only where the text within the Label is positioned, which can only be computed when the final width is known. Assume that the Labels return the following values from their MeasureCore calls: 153, 300 and 255. The Dock then decides that it needs to be 300 wide. The current state of the layout computation is illustrated in
Continuing with the example, during an Arrange procedure, an ArrangeCore call comes into the Dock control. Suppose the FinalSize is 300, since the parent of the Dock control wants the Dock control to be exactly 300 pixels wide. Because the Dock control wants to size its children to equal width, it calls Arrange on each of the Labels with a FinalSize of 300. This in turn invokes the ArrangeCore method on each of the Labels with a FinalSize of 300. The Labels now do the work required for centering the text. The final layout is illustrated in
As previously mentioned, a Layout Manager 318 is responsible for controlling the measure and arrange phases in one embodiment of the invention. To facilitate such control, elements store two properties: IsMeasureValid 336 and IsArrangeValid 338. The IsMeasureValid 336 and IsArrangeValid 338 properties are typically Boolean variables, set to either TRUE or FALSE. The Layout Manager 318 identifies elements requiring measurement and invokes a Measure procedure on them. Similarly, the Layout Manager 318 identifies elements requiring arrangement, and can invoke an Arrange procedure on them. To this end, the Layout Manager 318 maintains two separate queues: a measure queue 902 and an arrange queue 904, as seen in
An element indicates its need to be measured by calling an InvalidateMeasure procedure 306. In one embodiment, the InvalidateMeasure procedure 306 sets the element's IsMeasureValid property to FALSE and determines whether to place the element on the measure queue of the Layout Manager. An InvalidateArrange procedure 308 works similarly by setting an element's IsArrangeValid property to FALSE and determining whether to place the element on the arrange queue of the Layout Manager 318. Typically, if an element requires measurement, it also requires arrangement. However, an element may require arrangement without requiring measurement.
An example illustrating using the InvalidateMeasure procedure 306 is shown in
Additionally, if an element is remeasured and its DesiredSize changes, the element's parent is informed of the change, since the parent may now require remeasurement as well. For example, the additional text added to element 1002 results in its DesiredSize changing, but it may also result in the DesiredSize of its parent element 1006 changing. Thus an OnChildDesiredSizeChanged procedure 316 is available in one embodiment of the invention. The OnChildDesiredSizeChanged procedure 316 operates by calling InvalidateMeasure 306 on the parent element. This informs the Layout Manager that the parent element requires remeasurement, since its DesiredSize may have changed. In this way, measuring one element may cause other elements to need remeasurement.
Additionally, a single element with an invalid measure potentially causes its parent, grandparent, etc., to invalidate their measures as well. In one embodiment, an UpdateFullLayout procedure 310 is also provided. The UpdateFullLayout procedure 310 ensures that elements with invalid measurements are updated synchronously. The UpdateFullLayout procedure 310 operates by informing the LayoutManager 318 to remeasure the entire tree for the view.
Further optimizations relating to illustrative embodiments of the invention are included in a more detailed version of the Measure procedure 1100, shown in
The LayoutManager 318, as used in accordance with an embodiment of the invention, is now described. The LayoutManager 318 is a program typically residing on the operating system that manages the process of laying out graphical elements for rendering and presentation. The LayoutManager 318 is thus not typically accessible directly to a user or application developer. Rather, the LayoutManager 318 internally maintains lists of those elements requiring measurement and arranging due to invalidation. The LayoutManager 318 calls the Measure procedure 302 on elements requiring measurement, and calls the Arrange procedure 304 on elements requiring arrangement.
The illustrative LayoutManager 318 incorporates a number of execution features to increase performance. In one embodiment, an implementation of LayoutManager allocates a “pocket” containing a fixed number of items for the individual measure and arrange queues. When an element is to be added to a queue, the LayoutManager 318 takes an item from the pocket if items are available, and allocates an item otherwise. When an element is removed from a queue, its item is returned to the pocket. If the pocket is sufficiently large, very few allocations are necessary after the LayoutManager 318 begins running, thereby increasing performance/
In one embodiment, the size of the measure 902 and arrange queues 904 is limited to a maximum of 153 elements, and the LayoutManager 318 checks that this limit is not reached. This limit ensures that queue operations can be performed speedily while allowing an ample number of InvalidIslands to coexist. In other embodiments, other values for the maximum number of queue elements are used.
The LayoutManager 318 further ensures that the queues are continuously modified so that only roots are represented in the queues. When an element is invalidated via an InvalidateMeasure 306 or InvalidateArrange 308 call, the LayoutManager 318 determines whether the element is included in a current InvalidIsland. If so, the root of the InvalidIsland is already present in the appropriate queue, and the newly invalidated element need not be directly represented in the queue. For example, if element 1306 is invalidated, it is included in the InvalidIsland 1302 and represented by its root 1304.
Alternatively, it is also possible that when an element is invalidated, it forms a new root, requiring the removal of older roots from the queue. For example, if element 1308 is invalidated, it becomes the new root of InvalidIsland 1302. The LayoutManager then adds this element 1308 to the queue and removes the old root 1304 from the queue.
Turning to
At step 1410, the LayoutManager performs “orphan removal” on any descendents of the element that now appear on the measure queue. An embodiment of the invention accounts for the case when a parent is not interested in measuring or arranging its child. There are times when an application developer may wish that certain elements are not measured or arranged via a recursive call from their parents. When the root of an InvalidIsland is measured or arranged, such elements avoid the recursive measurement or arrangement and remain invalid. These elements are designated “orphans” and generally should not appear on the queue. The process of removing such elements from the queue is called “orphan removal.” The LayoutManager 318 continues by determining whether the measure queue 902 is empty during step 1402 and repeating the process if necessary.
The LayoutManager then turns to the Arrange phase, illustrated in
A programming interface (or more simply, interface) may be viewed as any mechanism, process, protocol for enabling one or more segment(s) of code to communicate with or access the functionality provided by one or more other segment(s) of code. Alternatively, a programming interface may be viewed as one or more mechanism(s), method(s), function call(s), module(s), object(s), etc. of a component of a system capable of communicative coupling to one or more mechanism(s), method(s), function call(s), module(s), etc. of other component(s). The term “segment of code” in the preceding sentence is intended to include one or more instructions or lines of code, and includes, e.g., code modules, objects, subroutines, functions, and so on, regardless of the terminology applied or whether the code segments are separately compiled, or whether the code segments are provided as source, intermediate, or object code, whether the code segments are utilized in a runtime system or process, or whether they are located on the same or different machines or distributed across multiple machines, or whether the functionality represented by the segments of code are implemented wholly in software, wholly in hardware, or a combination of hardware and software.
Notionally, a programming interface may be viewed generically, as shown in FIG. A1 or FIG. A2. FIG. A1 illustrates an interface Interface1 as a conduit through which first and second code segments communicate. FIG. A2 illustrates an interface as comprising interface objects I1 and I2 (which may or may not be part of the first and second code segments), which enable first and second code segments of a system to communicate via medium M. In the view of FIG. A2, one may consider interface objects I1 and I2 as separate interfaces of the same system and one may also consider that objects I1 and I2 plus medium M comprise the interface. Although FIGS. A1 and A2 show bi-directional flow and interfaces on each side of the flow, certain implementations may only have information flow in one direction (or no information flow as described below) or may only have an interface object on one side. By way of example, and not limitation, terms such as application programming interface (API), entry point, method, function, subroutine, remote procedure call, and component object model (COM) interface, are encompassed within the definition of programming interface.
Aspects of such a programming interface may include the method whereby the first code segment transmits information (where “information” is used in its broadest sense and includes data, commands, requests, etc.) to the second code segment; the method whereby the second code segment receives the information; and the structure, sequence, syntax, organization, schema, timing and content of the information. In this regard, the underlying transport medium itself may be unimportant to the operation of the interface, whether the medium be wired or wireless, or a combination of both, as long as the information is transported in the manner defined by the interface. In certain situations, information may not be passed in one or both directions in the conventional sense, as the information transfer may be either via another mechanism (e.g. information placed in a buffer, file, etc. separate from information flow between the code segments) or non-existent, as when one code segment simply accesses functionality performed by a second code segment. Any or all of these aspects may be important in a given situation, e.g., depending on whether the code segments are part of a system in a loosely coupled or tightly coupled configuration, and so this list should be considered illustrative and non-limiting.
This notion of a programming interface is known to those skilled in the art and is clear from the foregoing detailed description of the invention. There are, however, other ways to implement a programming interface, and, unless expressly excluded, these too are intended to be encompassed by the claims set forth at the end of this specification. Such other ways may appear to be more sophisticated or complex than the simplistic view of FIGS. A1 and A2, but they nonetheless perform a similar function to accomplish the same overall result. We will now briefly describe some illustrative alternative implementations of a programming interface.
A. Factoring
A communication from one code segment to another may be accomplished indirectly by breaking the communication into multiple discrete communications. This is depicted schematically in FIGS. B1 and B2. As shown, some interfaces can be described in terms of divisible sets of functionality. Thus, the interface functionality of FIGS. A1 and A2 may be factored to achieve the same result, just as one may mathematically provide 24, or 2 times 2 time 3 times 2. Accordingly, as illustrated in FIG. B1, the function provided by interface Interface1 may be subdivided to convert the communications of the interface into multiple interfaces Interface1A, Interface 1B, Interface 1C, etc. while achieving the same result. As illustrated in FIG. B2, the function provided by interface I1 may be subdivided into multiple interfaces I1a, I1b, I1c, etc. while achieving the same result. Similarly, interface I2 of the second code segment which receives information from the first code segment may be factored into multiple interfaces I2a, I2b, I2c, etc. When factoring, the number of interfaces included with the 1st code segment need not match the number of interfaces included with the 2nd code segment. In either of the cases of FIGS. B1 and B2, the functional spirit of interfaces Interface1 and I1 remain the same as with FIGS. A1 and A2, respectively. The factoring of interfaces may also follow associative, commutative, and other mathematical properties such that the factoring may be difficult to recognize. For instance, ordering of operations may be unimportant, and consequently, a function carried out by an interface may be carried out well in advance of reaching the interface, by another piece of code or interface, or performed by a separate component of the system. Moreover, one of ordinary skill in the programming arts can appreciate that there are a variety of ways of making different function calls that achieve the same result.
B. Redefinition
In some cases, it may be possible to ignore, add or redefine certain aspects (e.g., parameters) of a programming interface while still accomplishing the intended result. This is illustrated in FIGS. C1 and C2. For example, assume interface Interface1 of FIG. A1 includes a function call Square(input, precision, output), a call that includes three parameters, input, precision and output, and which is issued from the 1st Code Segment to the 2nd Code Segment. If the middle parameter precision is of no concern in a given scenario, as shown in FIG. C1, it could just as well be ignored or even replaced with a meaningless (in this situation) parameter. One may also add an additional parameter of no concern. In either event, the functionality of square can be achieved, so long as output is returned after input is squared by the second code segment. Precision may very well be a meaningful parameter to some downstream or other portion of the computing system; however, once it is recognized that precision is not necessary for the narrow purpose of calculating the square, it may be replaced or ignored. For example, instead of passing a valid precision value, a meaningless value such as a birth date could be passed without adversely affecting the result. Similarly, as shown in FIG. C2, interface I1 is replaced by interface I1′, redefined to ignore or add parameters to the interface. Interface I2 may similarly be redefined as interface I2′, redefined to ignore unnecessary parameters, or parameters that may be processed elsewhere. The point here is that in some cases a programming interface may include aspects, such as parameters, that are not needed for some purpose, and so they may be ignored or redefined, or processed elsewhere for other purposes.
C. Inline Coding
It may also be feasible to merge some or all of the functionality of two separate code modules such that the “interface” between them changes form. For example, the functionality of FIGS. A1 and A2 may be converted to the functionality of FIGS. D1 and D2, respectively. In FIG. D1, the previous 1st and 2nd Code Segments of FIG. A1 are merged into a module containing both of them. In this case, the code segments may still be communicating with each other but the interface may be adapted to a form which is more suitable to the single module. Thus, for example, formal Call and Return statements may no longer be necessary, but similar processing or response(s) pursuant to interface Interface1 may still be in effect. Similarly, shown in FIG. D2, part (or all) of interface I2 from FIG. A2 may be written inline into interface I1 to form interface I1″. As illustrated, interface I2 is divided into I2a and I2b, and interface portion I2a has been coded in-line with interface I1 to form interface I1″. For a concrete example, consider that the interface I1 from FIG. A2 performs a function call square (input, output), which is received by interface I2, which after processing the value passed with input (to square it) by the second code segment, passes back the squared result with output. In such a case, the processing performed by the second code segment (squaring input) can be performed by the first code segment without a call to the interface.
D. Divorce
A communication from one code segment to another may be accomplished indirectly by breaking the communication into multiple discrete communications. This is depicted schematically in FIGS. E1 and E2. As shown in FIG. E1, one or more piece(s) of middleware (Divorce Interface(s), since they divorce functionality and/or interface functions from the original interface) are provided to convert the communications on the first interface, Interface1, to conform them to a different interface, in this case interfaces Interface2A, Interface2B and Interface2C. This might be done, e.g., where there is an installed base of applications designed to communicate with, say, an operating system in accordance with an Interface1 protocol, but then the operating system is changed to use a different interface, in this case interfaces Interface2A, Interface2B and Interface2C. The point is that the original interface used by the 2nd Code Segment is changed such that it is no longer compatible with the interface used by the 1st Code Segment, and so an intermediary is used to make the old and new interfaces compatible. Similarly, as shown in FIG. E2, a third code segment can be introduced with divorce interface DI1 to receive the communications from interface I1 and with divorce interface DI2 to transmit the interface functionality to, for example, interfaces I2a and I2b, redesigned to work with DI2, but to provide the same functional result. Similarly, DI1 and DI2 may work together to translate the functionality of interfaces I1 and I2 of FIG. A2 to a new operating system, while providing the same or similar functional result.
E. Rewriting
Yet another possible variant is to dynamically rewrite the code to replace the interface functionality with something else but which achieves the same overall result. For example, there may be a system in which a code segment presented in an intermediate language (e.g. Microsoft IL, Java ByteCode, etc.) is provided to a Just-in-Time (JIT) compiler or interpreter in an execution environment (such as that provided by the Net framework, the Java runtime environment, or other similar runtime type environments). The JIT compiler may be written so as to dynamically convert the communications from the 1st Code Segment to the 2nd Code Segment, i.e., to conform them to a different interface as may be required by the 2nd Code Segment (either the original or a different 2nd Code Segment). This is depicted in FIGS. F1 and F2. As can be seen in FIG. F1, this approach is similar to the Divorce scenario described above. It might be done, e.g., where an installed base of applications are designed to communicate with an operating system in accordance with an Interface 1 protocol, but then the operating system is changed to use a different interface. The JIT Compiler could be used to conform the communications on the fly from the installed-base applications to the new interface of the operating system. As depicted in FIG. F2, this approach of dynamically rewriting the interface(s) may be applied to dynamically factor, or otherwise alter the interface(s) as well.
It is also noted that the above-described scenarios for achieving the same or similar result as an interface via alternative embodiments may also be combined in various ways, serially and/or in parallel, or with other intervening code. Thus, the alternative embodiments presented above are not mutually exclusive and may be mixed, matched and combined to produce the same or equivalent scenarios to the generic scenarios presented in FIGS. A1 and A2. It is also noted that, as with most programming constructs, there are other similar ways of achieving the same or similar functionality of an interface which may not be described herein, but nonetheless are represented by the spirit and scope of the invention, i.e., it is noted that it is at least partly the functionality represented by, and the advantageous results enabled by, an interface that underlie the value of an interface.
In view of the many possible embodiments to which the principles of the present invention may be applied, it should be recognized that the embodiments described herein with respect to the drawing figures are meant to be illustrative only and should not be taken as limiting the scope of the invention. For example, those of skill in the art will recognize that the illustrated embodiments can be modified in arrangement and detail without departing from the spirit of the invention. Although the invention is described in terms of software modules or components, those skilled in the art will recognize that such may be equivalently replaced by hardware components. Therefore, the invention as described herein contemplates all such embodiments as may come within the scope of the following claims and equivalents thereof.
Claims
1. A method for managing the preparation of a set of graphical elements for presentation, the method comprising:
- identifying a first subset of the elements where measurement is desirable;
- identifying a second subset of the elements where arrangement is desirable;
- executing a first series of operations for measuring the elements comprising the first subset; and
- executing a second series of operations for arranging the elements comprising the second subset.
2. The method of claim 1 wherein each element in the first subset has associated with it a respective island of elements, and each element in the second subset has associated with it a respective island of elements.
3. The method of claim 2 wherein identifying the first subset comprises using a first data structure to represent the first subset of the elements, and wherein identifying the second subset comprises using a second data structure to represent the second subset of the elements.
4. The method of claim 3 wherein the first and second data structures are queues.
5. The method of claim 3 wherein the first series of operations comprises:
- a) identifying a maximal element represented in the first data structure;
- b) removing the maximal element's representation in the first data structure;
- c) measuring the maximal element; and
- repeating the listed steps until the first data structure is empty.
6. The method of claim 3 wherein the second series of operations comprises:
- a) identifying a maximal element represented in the second data structure;
- b) removing the maximal element's representation in the second data structure;
- c) arranging the maximal element; and
- repeating the listed steps until the second data structure is empty.
7. The method of claim 5 wherein step c) comprises measuring an element from the island associated with the maximal element.
8. The method of claim 5 wherein step c) comprises:
- determining whether an element from the island associated with the maximal element requires measuring.
9. The method of claim 5 wherein the first series of operations further comprise:
- d) notifying a parent element of the maximal element that the measurements of the maximal element have changed.
10. The method of claim 9 wherein, in response to the notification, a representation of the parent element is placed in the first data structure.
11. The method of claim 3 wherein the number of elements represented in the first data structure cannot exceed a fixed maximum number.
12. The method of claim 3 wherein the number of elements represented in the second data structure does not exceed a fixed maximum number.
13. The method of claim 5 wherein the first series of operations further comprises:
- d) determining that an orphan element represented on the first data structure is not to be measured; and
- e) removing from the data structure the representation of the orphan element.
14. A system for managing the preparation of a set of graphical elements for presentation, the system comprising:
- a first data structure representing a first subset of the set of graphical elements requiring measurement;
- a second data structure representing a second subset of the set of graphical elements requiring arrangement;
- a first procedure using the first data structure for managing the measuring of elements; and
- a second procedure using the second data structure for managing the arranging of elements.
15. The system of claim 14 wherein the first procedure comprises the steps of:
- a) identifying a maximal element represented in the first data structure;
- b) removing the maximal element's representation in the first data structure;
- c) measuring the maximal element; and
- repeating the listed steps until the first data structure is empty.
16. The system of claim 14 wherein the second procedure comprises the steps of:
- a) identifying a maximal element represented in the second data structure;
- b) removing the maximal element's representation in the second data structure;
- c) arranging the maximal element; and
- repeating the listed steps until the second data structure is empty.
17. The system of claim 15 wherein step c) of the first procedure comprises:
- determining whether an element from an island associated with the maximal element requires measuring; and
- measuring the element from the island associated with the maximal element if it requires measuring.
18. The system of claim 15 wherein the first procedure further comprises:
- d) notifying a parent element of the maximal element that the measurements of the maximal element have changed.
19. The system of claim 15 wherein the first procedure further comprises:
- d) determining that an orphan element represented on the first data structure is not to be measured; and
- e) removing from the first data structure the representation of the orphan element.
20. A computer-readable medium including computer-executable instructions facilitating managing the preparation of graphical elements for presentation in a system, computer-executable instructions executing the steps of:
- identifying a first subset of the elements where measurement is desirable;
- identifying a second subset of the elements where arrangement is desirable;
- executing a first series of operations for measuring the elements comprising the first subset; and
- executing a second series of operations for arranging the elements comprising the second subset.
21. The computer-readable medium of claim 20 wherein each element in the first subset has associated with it a respective island of elements, and each element in the second subset has associated with it a respective island of elements.
22. The computer-readable medium of claim 21 wherein identifying the first subset comprises using a first data structure to represent the first subset of the elements, and wherein identifying the second subset comprises using a second data structure to represent the second subset of the elements.
23. The computer-readable medium of claim 22 wherein the first and second data structures are queues.
24. The computer-readable medium of claim 22 wherein the first series of operations comprises:
- a) identifying a maximal element represented in the first data structure;
- b) removing the maximal element's representation in the first data structure;
- c) measuring the maximal element; and
- repeating the listed steps until the first data structure is empty.
25. The computer-readable medium of claim 22 wherein the second series of operations comprises:
- a) identifying a maximal element represented in the second data structure;
- b) removing the maximal element's representation in the second data structure;
- c) arranging the maximal element; and
- repeating the listed steps until the second data structure is empty.
26. The computer-readable medium of claim 24 wherein step c) in the first series of operations comprises measuring an element from the island associated with the maximal element.
27. The computer-readable medium of claim 24 wherein step c) in the first series of operations comprises:
- determining whether an element from the island associated with the maximal element requires measuring.
28. The computer-readable medium of claim 24 wherein the first series of operations further comprises:
- d) notifying a parent element of the maximal element that the measurements of the maximal element have changed.
29. The computer-readable medium of claim 28 wherein the first series of operations further comprises:
- e) in response to the notification in step d), placing a representation of the parent element in the first data structure.
30. The computer-readable medium of claim 24 wherein the first series of operations further comprises:
- d) determining that an orphan element represented on the first data structure is not to be measured; and
- e) removing from the data structure the representation of the orphan element.
Type: Application
Filed: Oct 22, 2003
Publication Date: Apr 28, 2005
Patent Grant number: 7478340
Applicant: Microsoft Corporation (Redmond, WA)
Inventors: Sujal Parikh (Redmond, WA), Dmitry Titov (Redmond, WA)
Application Number: 10/691,349