Skip to content

Commit 0e1d5fe

Browse files
committed
Support Line Style on diagram objects
1 parent 77829ba commit 0e1d5fe

37 files changed

+595
-115
lines changed

com.archimatetool.canvas/src/com/archimatetool/canvas/factory/CanvasStickyUIProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public ImageDescriptor getImageDescriptor() {
6262
public boolean shouldExposeFeature(String featureName) {
6363
if(featureName == IArchimatePackage.Literals.LINE_OBJECT__LINE_COLOR.getName() ||
6464
featureName == IArchimatePackage.Literals.LINE_OBJECT__LINE_WIDTH.getName() ||
65+
featureName == IDiagramModelObject.FEATURE_LINE_STYLE ||
6566
featureName == IDiagramModelObject.FEATURE_DERIVE_ELEMENT_LINE_COLOR ||
6667
featureName == IDiagramModelObject.FEATURE_GRADIENT) {
6768
return false;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ private void drawFigure(Graphics graphics, Color background) {
162162
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
163163
setLineWidth(graphics, bounds);
164164

165+
setLineStyle(graphics);
166+
165167
graphics.setBackgroundColor(background);
166168
graphics.fillRectangle(bounds);
167169

com.archimatetool.editor/plugin.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,13 @@
431431
</propertySection>
432432
<propertySection
433433
afterSection="lineSection"
434-
class="com.archimatetool.editor.propertysections.LineOpacitySection"
435-
filter="com.archimatetool.editor.propertysections.LineOpacitySection$Filter"
436-
id="lineOpacitySection"
434+
class="com.archimatetool.editor.propertysections.LineSection2"
435+
filter="com.archimatetool.editor.propertysections.LineSection2$Filter"
436+
id="lineSection2"
437437
tab="appearance.tab">
438438
</propertySection>
439439
<propertySection
440-
afterSection="lineOpacitySection"
440+
afterSection="lineSection2"
441441
class="com.archimatetool.editor.propertysections.IconColorSection"
442442
filter="com.archimatetool.editor.propertysections.IconColorSection$Filter"
443443
id="iconColorSection"
@@ -451,7 +451,7 @@
451451
tab="appearance.tab">
452452
</propertySection>
453453
<propertySection
454-
afterSection="lineOpacitySection"
454+
afterSection="lineSection2"
455455
class="com.archimatetool.editor.propertysections.GroupBorderTypeSection"
456456
filter="com.archimatetool.editor.propertysections.GroupBorderTypeSection$Filter"
457457
id="groupBorderTypeSection"
@@ -491,7 +491,7 @@
491491
tab="appearance.tab">
492492
</propertySection>
493493
<propertySection
494-
afterSection="lineOpacitySection"
494+
afterSection="lineSection2"
495495
class="com.archimatetool.editor.propertysections.NoteBorderTypeSection"
496496
filter="com.archimatetool.editor.propertysections.NoteBorderTypeSection$Filter"
497497
id="noteBorderTypeSection"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* This program and the accompanying materials
3+
* are made available under the terms of the License
4+
* which accompanies this distribution in the file LICENSE.txt
5+
*/
6+
package com.archimatetool.editor.diagram.commands;
7+
8+
import com.archimatetool.editor.model.commands.FeatureCommand;
9+
import com.archimatetool.model.IDiagramModelObject;
10+
11+
12+
13+
/**
14+
* Line Style Command
15+
*
16+
* @author Phillip Beauvoir
17+
*/
18+
public class DiagramModelObjectLineStyleCommand extends FeatureCommand {
19+
20+
public DiagramModelObjectLineStyleCommand(IDiagramModelObject object, int style, int defaultValue) {
21+
super(Messages.DiagramModelObjectLineStyleCommand_0, object, IDiagramModelObject.FEATURE_LINE_STYLE, style, defaultValue);
22+
}
23+
}

com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/Messages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class Messages extends NLS {
4343

4444
public static String DiagramModelObjectAlphaCommand_0;
4545

46+
public static String DiagramModelObjectLineStyleCommand_0;
47+
4648
public static String DiagramModelObjectOutlineAlphaCommand_0;
4749

4850
public static String FillColorCommand_0;

com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ CreateDiagramObjectCommand_0=Create {0}
2323
2424
DeleteBendpointCommand_0=Remove Bendpoint
2525
DiagramModelObjectAlphaCommand_0=Change Opacity
26+
DiagramModelObjectLineStyleCommand_0=Change Line Style
2627
DiagramModelObjectOutlineAlphaCommand_0=Change Opacity
2728
2829
FillColorCommand_0=Change Fill Colour

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.archimatetool.editor.ui.FontFactory;
2626
import com.archimatetool.editor.ui.ImageFactory;
2727
import com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider;
28+
import com.archimatetool.editor.ui.factory.IObjectUIProvider;
2829
import com.archimatetool.editor.ui.factory.ObjectUIFactory;
2930
import com.archimatetool.editor.utils.StringUtils;
3031
import com.archimatetool.model.IArchimateElement;
@@ -142,6 +143,27 @@ protected void setDisabledState(Graphics graphics) {
142143
//graphics.setLineStyle(SWT.LINE_DASH);
143144
//graphics.setLineDash(new int[] { 4, 3 });
144145
}
146+
147+
/**
148+
* Set the line style
149+
* @param graphics
150+
*/
151+
protected void setLineStyle(Graphics graphics) {
152+
double scale = Math.min(FigureUtils.getFigureScale(this), 1.0); // only scale below 1.0
153+
154+
switch(getLineStyle()) {
155+
case IDiagramModelObject.LINE_STYLE_SOLID:
156+
default:
157+
graphics.setLineStyle(Graphics.LINE_SOLID);
158+
break;
159+
case IDiagramModelObject.LINE_STYLE_DASHED:
160+
graphics.setLineDash(new float[] { (float)(8 * scale), (float)(4 * scale) });
161+
break;
162+
case IDiagramModelObject.LINE_STYLE_DOTTED:
163+
graphics.setLineDash(new float[] { (float)(2 * scale), (float)(4 * scale) });
164+
break;
165+
}
166+
}
145167

146168
/**
147169
* Set the UI
@@ -247,6 +269,11 @@ protected int getLineWidth() {
247269
return fDiagramModelObject.getLineWidth();
248270
}
249271

272+
protected int getLineStyle() {
273+
IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(getDiagramModelObject());
274+
return provider != null && provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val ? val : IDiagramModelObject.LINE_STYLE_SOLID;
275+
}
276+
250277
@Override
251278
public void updateIconImage() {
252279
if(getIconicDelegate() != null) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ protected void setLineWidth(Graphics graphics, int lineWidth, Rectangle bounds)
129129
getOwner().setLineWidth(graphics, lineWidth, bounds);
130130
}
131131

132+
/**
133+
* Set line style
134+
* @param graphics
135+
*/
136+
protected void setLineStyle(Graphics graphics) {
137+
getOwner().setLineStyle(graphics);
138+
}
139+
132140
/**
133141
* Apply a gradient to the given Graphics instance and bounds using current fill color, alpha and gradient settings
134142
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public void drawFigure(Graphics graphics) {
3434
// Line Width
3535
setLineWidth(graphics, bounds);
3636

37+
setLineStyle(graphics);
38+
3739
graphics.setAlpha(getAlpha());
3840

3941
if(!isEnabled()) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public void drawFigure(Graphics graphics) {
3333

3434
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
3535
setLineWidth(graphics, bounds);
36+
37+
setLineStyle(graphics);
3638

3739
graphics.setAlpha(getAlpha());
3840

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public void drawFigure(Graphics graphics) {
3838

3939
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
4040
setLineWidth(graphics, bounds);
41+
42+
setLineStyle(graphics);
4143

4244
graphics.setAlpha(getAlpha());
4345

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ protected void paintFigure(Graphics graphics) {
105105
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
106106
setLineWidth(graphics, bounds);
107107

108+
setLineStyle(graphics);
109+
108110
if(fImage != null) {
109111
// Faster but no transparency
110112
if(useScaledImage) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ protected void drawFigure(Graphics graphics) {
5757
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
5858
setLineWidth(graphics, bounds);
5959

60+
setLineStyle(graphics);
61+
6062
graphics.setAlpha(getAlpha());
6163

6264
if(getDiagramModelObject().getBorderType() == IDiagramModelGroup.BORDER_TABBED) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ protected void paintFigure(Graphics graphics) {
116116
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
117117
if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE) {
118118
setLineWidth(graphics, bounds);
119+
setLineStyle(graphics);
119120
}
120121

121122
// Fill

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

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

4545
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
4646
setLineWidth(graphics, bounds);
47+
48+
setLineStyle(graphics);
4749

4850
PointList points = new PointList();
4951
points.addPoint(bounds.x + FLANGE, bounds.y);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ protected void drawFigure(Graphics graphics) {
6161
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
6262
setLineWidth(graphics, bounds);
6363

64-
// Scale line dashes below 1.0
65-
double scale = Math.min(FigureUtils.getGraphicsScale(graphics), 1.0);
66-
67-
graphics.setLineDash(new float[] { (float)(8 * scale), (float)(4 * scale) });
64+
setLineStyle(graphics);
6865

6966
graphics.setBackgroundColor(getFillColor());
7067
graphics.setForegroundColor(getLineColor());

com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/figures/StickyFigure.java

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

5151
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
5252
setLineWidth(graphics, bounds);
53+
54+
setLineStyle(graphics);
5355

5456
graphics.setBackgroundColor(getFillColor());
5557

com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/FormatPainterTool.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.archimatetool.editor.diagram.commands.ConnectionLineTypeCommand;
2020
import com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand;
2121
import com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand;
22+
import com.archimatetool.editor.diagram.commands.DiagramModelObjectLineStyleCommand;
2223
import com.archimatetool.editor.diagram.commands.DiagramModelObjectOutlineAlphaCommand;
2324
import com.archimatetool.editor.diagram.commands.FillColorCommand;
2425
import com.archimatetool.editor.diagram.commands.FontColorCommand;
@@ -112,6 +113,8 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) {
112113
CompoundCommand result = new CompoundCommand(Messages.FormatPainterTool_0);
113114

114115
IDiagramModelComponent sourceComponent = FormatPainterInfo.INSTANCE.getSourceComponent();
116+
117+
IObjectUIProvider sourceUIProvider = ObjectUIFactory.INSTANCE.getProvider(sourceComponent);
115118
IObjectUIProvider targetUIProvider = ObjectUIFactory.INSTANCE.getProvider(targetComponent);
116119

117120
// IFontAttribute
@@ -212,6 +215,15 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) {
212215
result.add(cmd);
213216
}
214217

218+
// Line Style
219+
if(targetUIProvider != null && sourceUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_LINE_STYLE)) {
220+
cmd = new DiagramModelObjectLineStyleCommand(target, (int)sourceUIProvider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE),
221+
(int)targetUIProvider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE));
222+
if(cmd.canExecute()) {
223+
result.add(cmd);
224+
}
225+
}
226+
215227
// Gradient
216228
if(targetUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_GRADIENT)) {
217229
cmd = new FeatureCommand("", target, IDiagramModelObject.FEATURE_GRADIENT, source.getGradient(), IDiagramModelObject.FEATURE_GRADIENT_DEFAULT); //$NON-NLS-1$

com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineOpacitySection.java

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)