Skip to content

Commit c336a82

Browse files
committed
Call applyLineWidthOffset() before using fills as well as outlines
- Otherwise there is a small gap between outline and fill which can be seen when zoomed in and when exporting as image
1 parent 5cec750 commit c336a82

13 files changed

Lines changed: 37 additions & 45 deletions

File tree

com.archimatetool.canvas/src/com/archimatetool/canvas/figures/CanvasBlockFigure.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,24 @@ private void drawFigure(Graphics graphics, Color background) {
131131

132132
graphics.setAntialias(SWT.ON);
133133

134+
boolean drawOutline = getBorderColor() != null && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE;
135+
Rectangle rect = drawOutline ? applyLineWidthOffset(graphics) : getBounds().getCopy();
136+
134137
// Fill
135138
graphics.setAlpha(getAlpha());
136139
graphics.setBackgroundColor(background);
137-
graphics.fillRectangle(getBounds().getCopy());
140+
graphics.fillRectangle(rect);
138141

139142
// Icon Image
140143
drawIconImage(graphics, getBounds().getCopy());
141144

142145
// Border
143-
if(getBorderColor() != null && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
146+
if(drawOutline) {
144147
setLineStyle(graphics);
145148
graphics.setAlpha(getLineAlpha());
146149
graphics.setForegroundColor(getBorderColor());
147150
graphics.setLineWidth(getLineWidth());
148-
graphics.drawRectangle(applyLineWidthOffset(graphics));
151+
graphics.drawRectangle(rect);
149152
}
150153

151154
graphics.popState();

com.archimatetool.canvas/src/com/archimatetool/canvas/figures/CanvasStickyFigure.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ protected void paintFigure(Graphics graphics) {
113113

114114
graphics.setAlpha(getAlpha());
115115

116-
Rectangle rect = getBounds().getCopy();
116+
boolean drawOutline = getBorderColor() != null;
117+
Rectangle rect = drawOutline ? applyLineWidthOffset(graphics) : getBounds().getCopy();
117118

118119
// Bug on Linux hi-res using Graphics.fillGradient()
119120
// See https://github.com/eclipse-platform/eclipse.platform.swt/issues/3107
@@ -131,8 +132,7 @@ protected void paintFigure(Graphics graphics) {
131132
drawIconImage(graphics, getBounds().getCopy());
132133

133134
// Border
134-
if(getBorderColor() != null) {
135-
rect = applyLineWidthOffset(graphics);
135+
if(drawOutline) {
136136
graphics.setAlpha(getLineAlpha());
137137
graphics.setLineWidth(getLineWidth());
138138

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RectangleFigureDelegate.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public RectangleFigureDelegate(AbstractDiagramModelObjectFigure owner) {
2828
public void drawFigure(Graphics graphics) {
2929
graphics.pushState();
3030

31-
Rectangle rect = getBounds();
31+
boolean drawOutline = getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE;
32+
33+
Rectangle rect = drawOutline ? applyLineWidthOffset(graphics) : getBounds();
3234

3335
// Fill
3436
fill(graphics, rect);
@@ -37,10 +39,10 @@ public void drawFigure(Graphics graphics) {
3739
drawIconImage(graphics, rect);
3840

3941
// Outline
40-
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
42+
if(drawOutline) {
4143
setLineStyle(graphics);
4244
graphics.setLineWidth(getLineWidth());
43-
drawOutline(graphics, applyLineWidthOffset(graphics));
45+
drawOutline(graphics, rect);
4446
}
4547

4648
graphics.popState();

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/DiagramImageFigure.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ protected void paintFigure(Graphics graphics) {
7878

7979
graphics.setAlpha(getDiagramModelObject().getAlpha());
8080

81-
Rectangle rect = getBounds().getCopy();
81+
boolean drawOutline = getBorderColor() != null && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE;
82+
Rectangle rect = drawOutline ? applyLineWidthOffset(graphics) : getBounds().getCopy();
8283

8384
if(fImage != null) {
8485
// Draw the image with checks ensuring minimum width and height
@@ -92,12 +93,12 @@ protected void paintFigure(Graphics graphics) {
9293
}
9394

9495
// Border
95-
if(getBorderColor() != null && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
96+
if(drawOutline) {
9697
setLineStyle(graphics);
9798
graphics.setAlpha(getDiagramModelObject().getLineAlpha());
9899
graphics.setForegroundColor(getBorderColor());
99100
graphics.setLineWidth(getLineWidth());
100-
graphics.drawRectangle(applyLineWidthOffset(graphics));
101+
graphics.drawRectangle(rect);
101102
}
102103

103104
graphics.popState();

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/GroupFigure.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ public IDiagramModelGroup getDiagramModelObject() {
5050
protected void drawFigure(Graphics graphics) {
5151
graphics.pushState();
5252

53-
Rectangle rect = getBounds().getCopy();
54-
5553
final boolean drawOutline = getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE;
54+
Rectangle rect = drawOutline ? applyLineWidthOffset(graphics) : getBounds().getCopy();
5655

5756
// Tabbed style
5857
if(getDiagramModelObject().getBorderType() == IDiagramModelGroup.BORDER_TABBED) {
@@ -96,8 +95,6 @@ protected void drawFigure(Graphics graphics) {
9695
graphics.setLineWidth(getLineWidth());
9796
setLineStyle(graphics);
9897

99-
rect = applyLineWidthOffset(graphics);
100-
10198
// Main rectangle
10299
graphics.drawRectangle(createMainRectangle(rect));
103100

@@ -132,7 +129,7 @@ protected void drawFigure(Graphics graphics) {
132129
graphics.setAlpha(getLineAlpha());
133130
graphics.setLineWidth(getLineWidth());
134131
setLineStyle(graphics);
135-
graphics.drawRectangle(applyLineWidthOffset(graphics));
132+
graphics.drawRectangle(rect);
136133
}
137134
}
138135

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ protected void paintFigure(Graphics graphics) {
9494

9595
graphics.setAntialias(SWT.ON);
9696

97-
Rectangle rect = getBounds().getCopy();
98-
9997
boolean drawBorder = getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE;
98+
Rectangle rect = drawBorder ? applyLineWidthOffset(graphics) : getBounds().getCopy();
10099

101100
// Dog ear
102101
if(getDiagramModelObject().getBorderType() == IDiagramModelNote.BORDER_DOGEAR) {
@@ -117,7 +116,7 @@ protected void paintFigure(Graphics graphics) {
117116
graphics.setForegroundColor(getLineColor());
118117
graphics.setLineWidth(getLineWidth());
119118
setLineStyle(graphics);
120-
path = createDogEarPath(applyLineWidthOffset(graphics));
119+
path = createDogEarPath(rect);
121120
graphics.drawPath(path);
122121
path.dispose();
123122
}
@@ -138,7 +137,7 @@ protected void paintFigure(Graphics graphics) {
138137
graphics.setForegroundColor(getLineColor());
139138
graphics.setLineWidth(getLineWidth());
140139
setLineStyle(graphics);
141-
graphics.drawRectangle(applyLineWidthOffset(graphics));
140+
graphics.drawRectangle(rect);
142141
}
143142
}
144143

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/AbstractMotivationFigure.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,10 @@ protected void drawFigure(Graphics graphics) {
3737

3838
graphics.pushState();
3939

40-
Rectangle rect;
41-
4240
final boolean drawOutline = getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE;
4341

4442
// Have to apply the offset for the fill also so it lines up with the outline
45-
if(drawOutline) {
46-
rect = applyLineWidthOffset(graphics);
47-
}
48-
else {
49-
rect = getBounds().getCopy();
50-
}
43+
Rectangle rect = drawOutline ? applyLineWidthOffset(graphics) : getBounds().getCopy();
5144

5245
// Fill
5346
graphics.setAlpha(getAlpha());

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/ApplicationComponentFigure.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public void drawFigure(Graphics graphics) {
4747

4848
graphics.pushState();
4949

50-
Rectangle rect = getBounds().getCopy();
50+
// Apply the offset for the fill also so it lines up with the outline
51+
Rectangle rect = applyLineWidthOffset(graphics);
5152

5253
// Main Fill
5354
graphics.setAlpha(getAlpha());
@@ -59,8 +60,6 @@ public void drawFigure(Graphics graphics) {
5960
// Icon
6061
drawIconImage(graphics, getBounds().getCopy(), 0, 0, 0, INDENT * 2);
6162

62-
rect = applyLineWidthOffset(graphics);
63-
6463
graphics.setLineWidth(getLineWidth());
6564
graphics.setAlpha(getLineAlpha());
6665
graphics.setForegroundColor(getLineColor());

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/CapabilityFigure.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ protected void drawFigure(Graphics graphics) {
4646

4747
Rectangle rect = getFigurePositionFromTextPosition(getBounds());
4848

49+
rect = applyLineWidthOffset(graphics, rect);
50+
4951
// block length
5052
float blockLength = Math.min(rect.height / 3.0f, rect.width / 3.0f);
5153
float figureLength = blockLength * 3;
@@ -71,8 +73,6 @@ protected void drawFigure(Graphics graphics) {
7173
graphics.setForegroundColor(getLineColor());
7274
graphics.setLineWidth(getLineWidth());
7375

74-
rect = applyLineWidthOffset(graphics, rect);
75-
7676
// Recaclulate these on new rect
7777
blockLength = Math.min(rect.height / 3.0f, rect.width / 3.0f);
7878
figureLength = blockLength * 3;

com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/GroupingFigure.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public GroupingFigure() {
4848
protected void drawFigure(Graphics graphics) {
4949
graphics.pushState();
5050

51-
Rectangle rect = getBounds().getCopy();
52-
5351
final boolean drawOutline = getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE;
52+
Rectangle rect = drawOutline ? applyLineWidthOffset(graphics) : getBounds().getCopy();
5453

5554
// Rectangle type
5655
if(getDiagramModelArchimateObject().getType() == 0) {
@@ -73,7 +72,7 @@ protected void drawFigure(Graphics graphics) {
7372
setLineStyle(graphics);
7473
graphics.setAlpha(getLineAlpha());
7574
graphics.setLineWidth(getLineWidth());
76-
graphics.drawRectangle(applyLineWidthOffset(graphics));
75+
graphics.drawRectangle(rect);
7776
}
7877
}
7978
// Tabbed
@@ -118,8 +117,6 @@ protected void drawFigure(Graphics graphics) {
118117
graphics.setLineWidth(getLineWidth());
119118
setLineStyle(graphics);
120119

121-
rect = applyLineWidthOffset(graphics);
122-
123120
// Main rectangle
124121
graphics.drawRectangle(createMainRectangle(rect));
125122

0 commit comments

Comments
 (0)