Analysis
Overview
Z-order of frames is an ordering of overlapping frames, so that one frame can hide part or all of another. When two frames overlap, their z-order determines which one appears on top of the other. The frame with higher z-order appears on the top. When a frame is created its z-order is the highest among the frames in the page. Two frames can't have the same z-order. When focus is requested to a frame, the frame appears on the top of the others but its z-order in the model doesn't change. When the same frame lose focus, it appears on the appropriate layer. The way to change the z-order is with the appropriate halo buttons (at least this is for now). If a frame has z-order equal to 4 and its z-order is increased to 5, then the frame which had z-order 5 before that will become with z-order 4.
Task requirements
- The frame should have z-order and to be displayed according to it.
- The frame should provide halo buttons to increase and decrease the z-order of the frame.
- The z-order of the frame should follow the concept given in the overview of the task.
Task result
- The result of the task should be source code.
Implementation idea
- Create z-order property in the model of the frame where the frame will keep its z-order.
- Use JLayerPane and the setLayer() method to visualize the different z-orders of the frames.
Related
How to demo
- Create two frames.
- Assert that the second frame has higher z-order.
- Increase the z-order of the first created frame.
- Assert that the first created frame has higher z-order than the second one.
- Decrease the z-order of the first created frame.
- Assert that the second created frame has higher z-order than the first one.
- Create some more frame.
- Assert that the given rules are valid for more that two frames.
Design
- The z-order of a frame is its index in the frames list. This guarantees:
- Each new frame automatically gets higher z-order than all other.
- No two frames have the same z-order.
- In class org.sophie2.base.model.book.Frame:
- auto property zOrder of type Integer
- Integer compute() method: gets the index of current frame in the list of frames in current page
- void doSet(Integer value) method: moves current frame to the position with the given index.
- auto property zOrder of type Integer
- In FrameLogic:
- Z_ORDER_DOWN
- creates new AutoChange which decreases the property Frame.zOrder
- Z_ORDER_UP - analogically
- Z_ORDER_DOWN
- Create two halo buttons in org.sophie2.main.app.halos.frame
- FrameZOrderDownHaloButton and FrameZOrderUpHaloButton, extend ClickHaloButton
- attach them to MainHaloMenu
- set icons - "zOrderDown.png" and "zOrderUp.png"
- class ZOrderUpButton - analogically
Implementation
(Implementation results should be described and linked here (from the wiki or the repository))
Testing
Comments
(Write comments for this or later revisions here.)