Skip to content

Commit

Permalink
Support Line Style 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillipus committed Oct 7, 2024
1 parent b051cf9 commit 0012d51
Show file tree
Hide file tree
Showing 14 changed files with 398 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public ImageDescriptor getImageDescriptor() {
public boolean shouldExposeFeature(String featureName) {
if(featureName == IArchimatePackage.Literals.LINE_OBJECT__LINE_COLOR.getName() ||
featureName == IArchimatePackage.Literals.LINE_OBJECT__LINE_WIDTH.getName() ||
featureName == IDiagramModelObject.FEATURE_LINE_STYLE ||
featureName == IDiagramModelObject.FEATURE_DERIVE_ELEMENT_LINE_COLOR ||
featureName == IDiagramModelObject.FEATURE_GRADIENT) {
return false;
Expand Down
12 changes: 6 additions & 6 deletions com.archimatetool.editor/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,13 @@
</propertySection>
<propertySection
afterSection="lineSection"
class="com.archimatetool.editor.propertysections.LineOpacitySection"
filter="com.archimatetool.editor.propertysections.LineOpacitySection$Filter"
id="lineOpacitySection"
class="com.archimatetool.editor.propertysections.LineSection2"
filter="com.archimatetool.editor.propertysections.LineSection2$Filter"
id="lineSection2"
tab="appearance.tab">
</propertySection>
<propertySection
afterSection="lineOpacitySection"
afterSection="lineSection2"
class="com.archimatetool.editor.propertysections.IconColorSection"
filter="com.archimatetool.editor.propertysections.IconColorSection$Filter"
id="iconColorSection"
Expand All @@ -451,7 +451,7 @@
tab="appearance.tab">
</propertySection>
<propertySection
afterSection="lineOpacitySection"
afterSection="lineSection2"
class="com.archimatetool.editor.propertysections.GroupBorderTypeSection"
filter="com.archimatetool.editor.propertysections.GroupBorderTypeSection$Filter"
id="groupBorderTypeSection"
Expand Down Expand Up @@ -491,7 +491,7 @@
tab="appearance.tab">
</propertySection>
<propertySection
afterSection="lineOpacitySection"
afterSection="lineSection2"
class="com.archimatetool.editor.propertysections.NoteBorderTypeSection"
filter="com.archimatetool.editor.propertysections.NoteBorderTypeSection$Filter"
id="noteBorderTypeSection"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This program and the accompanying materials
* are made available under the terms of the License
* which accompanies this distribution in the file LICENSE.txt
*/
package com.archimatetool.editor.diagram.commands;

import com.archimatetool.editor.model.commands.FeatureCommand;
import com.archimatetool.model.IDiagramModelObject;



/**
* Line Style Command
*
* @author Phillip Beauvoir
*/
public class DiagramModelObjectLineStyleCommand extends FeatureCommand {

public DiagramModelObjectLineStyleCommand(IDiagramModelObject object, int style) {
super("Change Line Style", object,
IDiagramModelObject.FEATURE_LINE_STYLE, style, IDiagramModelObject.FEATURE_LINE_STYLE_DEFAULT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,27 @@ protected void setDisabledState(Graphics graphics) {
//graphics.setLineStyle(SWT.LINE_DASH);
//graphics.setLineDash(new int[] { 4, 3 });
}

/**
* Set the line style
* @param graphics
*/
protected void setLineStyle(Graphics graphics) {
double scale = Math.min(FigureUtils.getFigureScale(this), 1.0); // only scale below 1.0

switch(getLineStyle()) {
case 0:
default:
graphics.setLineStyle(Graphics.LINE_SOLID);
break;
case 1:
graphics.setLineDash(new float[] { (float)(8 * scale), (float)(4 * scale) });
break;
case 2:
graphics.setLineDash(new float[] { (float)(1 * scale), (float)(4 * scale) });
break;
}
}

/**
* Set the UI
Expand Down Expand Up @@ -247,6 +268,10 @@ protected int getLineWidth() {
return fDiagramModelObject.getLineWidth();
}

protected int getLineStyle() {
return fDiagramModelObject.getLineStyle();
}

@Override
public void updateIconImage() {
if(getIconicDelegate() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ protected void setLineWidth(Graphics graphics, int lineWidth, Rectangle bounds)
getOwner().setLineWidth(graphics, lineWidth, bounds);
}

/**
* Set line style
* @param graphics
*/
protected void setLineStyle(Graphics graphics) {
getOwner().setLineStyle(graphics);
}

/**
* Apply a gradient to the given Graphics instance and bounds using current fill color, alpha and gradient settings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public void drawFigure(Graphics graphics) {

// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, bounds);

setLineStyle(graphics);

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) {
result.add(cmd);
}

// Line Style
if(targetUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_LINE_STYLE)) {
cmd = new FeatureCommand("", target, IDiagramModelObject.FEATURE_LINE_STYLE, source.getLineStyle(), IDiagramModelObject.FEATURE_LINE_STYLE_DEFAULT); //$NON-NLS-1$
if(cmd.canExecute()) {
result.add(cmd);
}
}

// Gradient
if(targetUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_GRADIENT)) {
cmd = new FeatureCommand("", target, IDiagramModelObject.FEATURE_GRADIENT, source.getGradient(), IDiagramModelObject.FEATURE_GRADIENT_DEFAULT); //$NON-NLS-1$
Expand Down

This file was deleted.

Loading

0 comments on commit 0012d51

Please sign in to comment.