Analysis
Overview
When the fill style is "pattern", the background of the frame or the page becomes another image which is repeated. This revision only requires selecting an image and repeating it.
In future revisions of this task, it would be nice to allow pattern rotation, resizing, and offset as well as selecting an image through drag and drop; because of these settings it will be necessary to have a pattern settings window.
Task requirements
- If the user chooses the PATTERN fill type in the frame or page background & border HUD, a "select pattern" button should be shown instead of the color square.
- The default pattern fill is empty.
- When the pattern settings button is clicked, it brings up a file dialogue prompting the user to select an image for the pattern. Clicking this when a pattern has already been set replaces the images with a new one.
Task result
The result of this task is source code.
The visible result of this task is visible image pattern filling.
Implementation idea
Use the current Filling interface to create ImmPattern class which will consist of image to be patterned and some other things (decide in the design section).
Related
FRAME_APPEARANCE_HALO_AND_HUD_R0
FRAME_FILLING_GRADIENT_R0
FRAME_FILLING_SOLID_R0
FRAME_FILLING_IMAGE_R0
How to demo
- Make a new book.
- Open page's background & border HUD, choose pattern fill, set an image as the pattern.
- Add a text frame to a page. Open frame's background & border HUD, choose pattern fill, select another image to use at the pattern.
- Demonstrate opacity by clicking on the frame visibility check box so that the frame becomes invisible and the image pattern becomes transparent.
Design
- Implementation will follow the following class diagram:
- The following classes will be created:
- org.sophie2.base.commons.util.ImmPattern
- org.sophie2.main.app.halos.huds.BackgroundPatternField
- The following classes and enumerations will be extended:
- org.sophie2.main.app.halos.huds.BackgroundAndBorderHud
- org.sophie2.main.app.commons.frame.FrameView
- org.sophie2.main.dialogs.input.BackgroundType
- Class ImmPattern will be immutable.
- The internal representation of a pattern will be a ImmImage object.
- The TexturePaint class from the standard Java library will be used, initialized with the image from ImmPattern. This allows us to use the preexisting algorithm for tiling.
- An ImmPatternTest JUnit test case will be created that will test for immutability and correct construction: [3069], [3129].
- Changesets: [3034].
- The design related code will be merged together with the implementation - pap.
Implementation
The Implementation differs from the design mainly in that more classes are changed to realize the functionality. PageWorkArea and FrameView classes had to be changed to make the pattern fill work for pages and frames accordingly.
Here is a complete list of changesets (some changes are redundant caused by problems with the SVN):
[3034]
[3071]
[3116]
[3124]
[3128]
[3129]
Merged into the trunk in [3157].
Testing
Comments
- The button may contain currently selected pattern
- The image is with it's default size tiled