Skip to content

Commit

Permalink
Allow Rulers with a Custom Dots Per Unit Setting (#613)
Browse files Browse the repository at this point in the history
With this change the API of the RulerProvider class is extended with a
custom dots per unit setting. This allows clients to use our default
Ruler Figure adjusted to application specific resolutions and drawing
scales.

As part of this change the RulerFigure was cleaned by splitting the
paintFigure method in several methods for increased readability and
maintainability.

Bugzilla entry: https://bugs.eclipse.org/bugs/show_bug.cgi?id=105493

Co-authored-by: Patrick Ziegler <[email protected]>
  • Loading branch information
azoitl and ptziegler authored Nov 11, 2024
1 parent fb4a5ff commit 98cd019
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 142 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- The look of the palette viewer can be customized via the ColorProvider interface. Supported model elements and properties are:
- PaletteEntry (hover, selection)
- PaletteTemplateEntry (selection)
- Rulers can now be created with custom dots per unit settings. The `RulerProvider` interface has now a new unit constant `UNIT_CUSTOM`. When this is used the `RulerProvider` can provide via the new `getCustomRulerDPU()` an application specific dots per unit setting.

## Zest
- Integration of Zest 2.0 development branch. See the [wiki](https://github.com/eclipse-gef/gef-classic/wiki/Zest#zest-2x) for more details. In case only default layout algorithms are used, the initial migration should be seamless. Otherwise the algorithms can be adapted to run in legacy mode by extending `AbstractLayoutAlgorithm.Zest1` or have to be re-implemented using the new API by extending `AbstractLayoutAlgorithm`. Note that this legacy mode will be removed in a future release. The following list contains the most significant, deprecated features:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public void setUp() {
constraint = 42;
figure = new Figure();
dummy = new Figure();
container = new RulerFigure(true, RulerProvider.UNIT_CENTIMETERS);
container = new RulerFigure(true, new RulerProvider() {
@Override
public int getUnit() {
return RulerProvider.UNIT_CENTIMETERS;
}
});
container.add(figure, (Object) constraint);
container.add(dummy);
rulerLayout = (RulerLayout) container.getLayoutManager();
Expand Down
8 changes: 8 additions & 0 deletions org.eclipse.gef/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/gef/rulers/RulerProvider.java" type="org.eclipse.gef.rulers.RulerProvider">
<filter id="336658481">
<message_arguments>
<message_argument value="org.eclipse.gef.rulers.RulerProvider"/>
<message_argument value="UNIT_CUSTOM"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/gef/ui/actions/AlignmentRetargetAction.java" type="org.eclipse.gef.ui.actions.AlignmentRetargetAction">
<filter id="571473929">
<message_arguments>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2023 IBM Corporation and others.
* Copyright (c) 2003, 2024 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -96,7 +96,7 @@ protected void createEditPolicies() {
*/
@Override
protected IFigure createFigure() {
RulerFigure ruler = new RulerFigure(isHorizontal(), getRulerProvider().getUnit());
RulerFigure ruler = new RulerFigure(isHorizontal(), getRulerProvider());
if (ruler.getUnit() == RulerProvider.UNIT_PIXELS) {
ruler.setInterval(100, 2);
}
Expand Down
Loading

0 comments on commit 98cd019

Please sign in to comment.