wiki:ELEMENT_VIEWS_REDESIGN_R0
Last modified 16 years ago Last modified on 09/16/09 17:06:32

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=ELEMENT_VIEWS_REDESIGN_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

The goal of this task is to clear up the design and hierarchy of resource views and to complete their implementation.

Task requirements

  • Look through the following classes, clear up their design, complete their implementation and remove obsolete methods and properties:
    • ElementView and all its subclasses
    • BookView
    • PageWorkArea (including connected classes such as PwaSelecter)
  • This will include changes everywhere they are used.
  • Create a simple demo that shows a page and some elements in it to demonstrate the views hierarchy.

Task result

The result of this task will be a UML diagram and source code.

Implementation idea

Use the suggested by milo hierarchy of element views.

UNPLANNED_MAIN_WINDOW_REFACTORING_R0

How to demo

Run the demo.

Design

The hierarchy of the element views will generally follow the hierarchy in the model described in [GROUP_BOOK_MODEL_REDESIGN_R0]

source:branches/second_resource_refactoring/sophie2-platform/doc/uml-design-diagrams/ElementViewsClassDiagram.jpg

  • ResourceView - base interface for views that show resources. Implementors should have a constructor by ResourceAccess and a method to get a helper for the resource the view shows.

  • BookView - a view that shows a book.
    • There are 3 helper classes connected with BookView:
      • BookViewOptions - An immutable class that contains settings for displaying a book, such as zoom level, mode (preview or author), should frames and the connections between them be outlined.
      • BookExtrasState - An immutable class that represents the state of book extras in a particular moment - all known book extras, which of them are shown and which one is current.
      • BookTimeState - An immutable class that contains information about the current page, the local time of the book and the local time of the current page.
    • A BookView has:
      • private RwProp<BookViewOptions> options() with public getter and setter. The setter should assert that we cannot switch between author and preview mode by changing the options value.
      • public RwProp<BookExtrasState> extrasState() - trackes the current state of page extras.
      • private RwProp<BookTimeState> timeState() - used for timelines.
      • some helper methods to get a specific page view.
      • owns private RwListProp<RootPageView> openPageViews() - ensures that the parent property of the views for all open pages is correct and they will be kept alive.
  • ElementView - a view of a page element which renders as a scene object and has a timeline.
    • Main properties, methods and responsibilities:
      • public Prop<SceneElement> sceneElement() - the scene element representation of its model.
        • By default it is composite scene element containing the scene elements of all subviews.
        • If you want to add other child scene elements, you can override the protected void setupSceneElements(List<SceneElement> res) method.
      • owns ListProp<ElementView> elementViews() - a list of <code>ElementViews</code> for all sub-elements of this view's model.
        • This guarantees that the parent of the subviews will be correct and that they will be kept alive.
      • private RwProp<TimePos> localTime() with getter and setter - used for timelines.
      • ImmColor computeColor() - used to mark elements that are invisible, inactive or out of the edit scope.
      • helper methods:
        • BookView getBookView()
        • BookViewOptions getViewOptions()
        • PageWorkArea getPwa()
    • RootPageView
      • responsible for visualizing page border and background
      • owns AutoProperty<PartPageView> mainPartView() - the main PartPageView that contains views for all children of the page.
      • owns AutoListProperty<PartPageView> extraPartViews() - a list of views for all visible page extras.
    • PartPageView - base class for:
      • MainPageView - a view for all page elements, responsible for clipping the page in preview mode.
      • ExtraPageView - a view for a page extra.
    • GroupView - a view for a group of elements.
    • FrameView - a base class for all views of frames.
      • takes care of all common things such as border, background, content location and rotation, resize areas and outlines.
      • its subclasses must implement the protected SceneElement makeContentElement() method.
    • AudioAnnotationView
    • StickyView

  • PageWorkArea - a view that calculates what is to be displayed from a page and uses scenes to display the contents of a page.
    • PwaSelector - a helper class responsible for managing the edit scope and selection in a particular PageWorkArea.
      • The edit scope is an ElementView in which one can add new sub-elements and whose sub-elements can be changed or removed. By default this should be the MainPageView of the current page. When the user enters a group, the edit scope should become the responsible GroupView.
      • One can only select ElementViews that are sub-views of the edit scope or a part of the current bookExtra.
      • ScopeRel - enum, inner for PwaSelector, defines the relation between an ElementView and the edit scope.
    • Prop<CompositeSceneElement> rootSceneElement() - a composite scene element, consisting of the RootPageView's scene element, selectionRisenElement(), selectionDragElement() and selectionBoundsElement()
      • selectionRisenElement() - a semi-transparent copy of the selected element that is drawn above everything else.
      • selectionDragElement() - drag to select SceneElement.
      • selectionBoundsElement() - the bounding rectangle of the currently selected elements.
    • Prop<JDesktopPane> swingComponent() - the swing representation of this PageWorkArea - a pane which contains a layer for the scene visual, and a layer for the halos.
  • Selection logic:
    • Select/deselect single elements (by cliching on them) - fix ElementLogic.ON_TOGGLE_ELEMENT_SELECTION
    • Drag to select - fix ScenePageLogic
  • Menus, halos and huds
    • check their computeVisible() method in order to show them
    • register all already written hud (bound control) logics as extensions in MainAppHalosModule
    • check if hud's logics use correct ResourceAccesses
    • implement templating logic

Implementation

Done according to the design.

Source code: [5989], [6020], [6133], [6188], [6230], [6238], [6308], [6345], [6350], [6360], [6482]

  • Selection:
    • PwaSelector - as described in the design it is responsible for managing the edit scope and selection. Its select methods are used by the selection logics.
    • ElementLogic has a single operation ON_TOGGLE_ELEMENT_SELECTION which handles selecting/deselecting elements by clicking on them. More than one element can be selected by holding down the Shift key.
    • ScenePageLogic's operation DRAG_TO_SELECT_PAGE_ELEMENTS handles selecting page elements by dragging.
      • This operation is invoked on MOUSE_PRESSED and uses a MouseCapture object to follow the position of the mouse.
      • The point where the mouse was pressed and the current position of the mouse define the selection rectangle. All page elements whose bounds are inside this rectangle are marked as selected.
    • Currently stickies can be selected by clicking on them and not by dragging.
  • Templating and locking background, border and insets (BorderAndBackgroundHud, InsetsHud)
    • boolean isModeMatch(VisualElement element, TemplatedKey<?>/CompositeKey key, Mode mode) - a helper method that checks the mode of a specified key.
    • 'Use template' mode:
      • When a key is in template mode, the appropriate '... template' checkbox is selected.
      • All other controls that may change its value are enabled. If the user changes something, the key is no longer in 'use template' mode and the checkbox is updated.
      • ON_xxx_USE_TEMPLATE_SUBMIT operation in HudsLogic switches between template and custom mode.
        • when switching to template mode the key's value is set to null
        • when switching from template to custom mode, the key's value is copied
    • 'Locked' mode:
      • all controls that may change a key's value that is in locked mode should be disabled.
      • ON_xxx_LOCKED_SUBMIT operation in HudsLogic locks a key, i.e. prevents it from any changes.
        • before locking a key, we copy its value to make sure it is not in 'use template' mode.
    • The methods that set template or lock to border and background are in StyledElementH.

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)