Skip to content

Commit

Permalink
Add "None" line style
Browse files Browse the repository at this point in the history
- Note - Canvas Block and Canvas Image have a "None" border colour and Note has a "None" border type so in these cases the "None" option is doubled up
  • Loading branch information
Phillipus committed Dec 15, 2024
1 parent ba07da5 commit 2e5b602
Show file tree
Hide file tree
Showing 24 changed files with 135 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.archimatetool.editor.diagram.figures.TextPositionDelegate;
import com.archimatetool.editor.ui.ColorFactory;
import com.archimatetool.editor.utils.StringUtils;
import com.archimatetool.model.IDiagramModelObject;


/**
Expand Down Expand Up @@ -159,10 +160,11 @@ private void drawFigure(Graphics graphics, Color background) {
bounds.width--;
bounds.height--;

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

setLineStyle(graphics);
if(getBorderColor() != null && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, bounds);
setLineStyle(graphics);
}

graphics.setBackgroundColor(background);
graphics.fillRectangle(bounds);
Expand All @@ -171,7 +173,7 @@ private void drawFigure(Graphics graphics, Color background) {
drawIconImage(graphics, bounds);

// Border
if(getBorderColor() != null) {
if(getBorderColor() != null && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getBorderColor());
graphics.drawRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
Expand Down
Binary file added com.archimatetool.editor/img/line-none.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public DiagramModelObjectLineStyleCommand(IDiagramModelObject dmo, int style) {

@Override
public boolean canExecute() {
return super.canExecute() && style >= IDiagramModelObject.LINE_STYLE_SOLID && style <= IDiagramModelObject.LINE_STYLE_DOTTED;
return super.canExecute() && style >= IDiagramModelObject.LINE_STYLE_SOLID && style <= IDiagramModelObject.LINE_STYLE_NONE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ protected void setLineWidth(Graphics graphics, int lineWidth, Rectangle bounds)
getOwner().setLineWidth(graphics, lineWidth, bounds);
}

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

/**
* Set line style
* @param graphics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Pattern;

import com.archimatetool.model.IDiagramModelObject;



/**
Expand All @@ -31,10 +33,11 @@ public void drawFigure(Graphics graphics) {
bounds.width--;
bounds.height--;

// Line Width
setLineWidth(graphics, bounds);

setLineStyle(graphics);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// 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 All @@ -51,9 +54,11 @@ public void drawFigure(Graphics graphics) {
disposeGradientPattern(graphics, gradient);

// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawOval(bounds);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawOval(bounds);
}

// Image Icon
Rectangle imageArea = new Rectangle(bounds.x + (bounds.width / 6), bounds.y + (bounds.height / 6),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Pattern;

import com.archimatetool.model.IDiagramModelObject;



/**
Expand All @@ -31,11 +33,12 @@ public void drawFigure(Graphics graphics) {
bounds.width--;
bounds.height--;

// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, bounds);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, bounds);
setLineStyle(graphics);
}

setLineStyle(graphics);

graphics.setAlpha(getAlpha());

if(!isEnabled()) {
Expand All @@ -52,9 +55,11 @@ public void drawFigure(Graphics graphics) {
disposeGradientPattern(graphics, gradient);

// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawRectangle(bounds);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawRectangle(bounds);
}

// Icon
// getOwner().drawIconImage(graphics, bounds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Pattern;

import com.archimatetool.model.IDiagramModelObject;




Expand All @@ -36,10 +38,11 @@ public void drawFigure(Graphics graphics) {
bounds.width--;
bounds.height--;

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

setLineStyle(graphics);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// 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 All @@ -57,9 +60,11 @@ public void drawFigure(Graphics graphics) {
disposeGradientPattern(graphics, gradient);

// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawRoundRectangle(bounds, fArc.width, fArc.height);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawRoundRectangle(bounds, fArc.width, fArc.height);
}

// Image Icon
Rectangle imageArea = new Rectangle(bounds.x + 2, bounds.y + 2, bounds.width - 4, bounds.height - 4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.archimatetool.editor.ui.IArchiImages;
import com.archimatetool.editor.ui.ImageFactory;
import com.archimatetool.model.IDiagramModelImage;
import com.archimatetool.model.IDiagramModelObject;


/**
Expand Down Expand Up @@ -102,10 +103,11 @@ protected void paintFigure(Graphics graphics) {
bounds.width--;
bounds.height--;

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

setLineStyle(graphics);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, bounds);
setLineStyle(graphics);
}

if(fImage != null) {
// Faster but no transparency
Expand All @@ -130,7 +132,7 @@ protected void paintFigure(Graphics graphics) {
}

// Border
if(getBorderColor() != null) {
if(getBorderColor() != null && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getDiagramModelObject().getLineAlpha());
graphics.setForegroundColor(getBorderColor());
graphics.drawRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ protected void drawFigure(Graphics graphics) {
bounds.width--;
bounds.height--;

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

setLineStyle(graphics);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// 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 Expand Up @@ -111,18 +112,20 @@ protected void drawFigure(Graphics graphics) {
}

// Line
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());

Path path = new Path(null);
path.moveTo(bounds.x, bounds.y + tabHeight);
path.lineTo(bounds.x, bounds.y);
path.lineTo(bounds.x + tabWidth, bounds.y);
path.lineTo(bounds.x + tabWidth, bounds.y + tabHeight);
graphics.drawPath(path);
path.dispose();

graphics.drawRectangle(bounds.x, bounds.y + tabHeight, bounds.width, bounds.height - tabHeight);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());

Path path = new Path(null);
path.moveTo(bounds.x, bounds.y + tabHeight);
path.lineTo(bounds.x, bounds.y);
path.lineTo(bounds.x + tabWidth, bounds.y);
path.lineTo(bounds.x + tabWidth, bounds.y + tabHeight);
graphics.drawPath(path);
path.dispose();

graphics.drawRectangle(bounds.x, bounds.y + tabHeight, bounds.width, bounds.height - tabHeight);
}
}
else {
graphics.setBackgroundColor(getFillColor());
Expand All @@ -139,9 +142,11 @@ protected void drawFigure(Graphics graphics) {
}

// Line
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());
graphics.drawRectangle(bounds);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setForegroundColor(getLineColor());
graphics.setAlpha(getLineAlpha());
graphics.drawRectangle(bounds);
}
}

graphics.popState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.archimatetool.editor.diagram.figures.TextPositionDelegate;
import com.archimatetool.editor.ui.textrender.TextRenderer;
import com.archimatetool.model.IDiagramModelNote;
import com.archimatetool.model.IDiagramModelObject;


/**
Expand Down Expand Up @@ -114,7 +115,7 @@ protected void paintFigure(Graphics graphics) {
bounds.height--;

// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE) {
if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
setLineWidth(graphics, bounds);
setLineStyle(graphics);
}
Expand Down Expand Up @@ -151,7 +152,7 @@ protected void paintFigure(Graphics graphics) {
// Icon
drawIconImage(graphics, bounds);

if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE) {
if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPolygon(points);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.archimatetool.editor.diagram.figures.AbstractTextControlContainerFigure;
import com.archimatetool.editor.diagram.figures.FigureUtils;
import com.archimatetool.model.IDiagramModelObject;


/**
Expand Down Expand Up @@ -42,10 +43,11 @@ protected void drawFigure(Graphics graphics) {
bounds.width--;
bounds.height--;

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

setLineStyle(graphics);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, bounds);
setLineStyle(graphics);
}

PointList points = new PointList();
points.addPoint(bounds.x + FLANGE, bounds.y);
Expand Down Expand Up @@ -76,9 +78,11 @@ protected void drawFigure(Graphics graphics) {
disposeGradientPattern(graphics, gradient);

// Line
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPolygon(points);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPolygon(points);
}

// Image Icon
Rectangle imageArea = new Rectangle(bounds.x + FLANGE / 2, bounds.y + FLANGE / 2, bounds.width - FLANGE, bounds.height - FLANGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.archimatetool.editor.diagram.figures.AbstractTextControlContainerFigure;
import com.archimatetool.editor.diagram.figures.FigureUtils;
import com.archimatetool.model.IDiagramModelObject;
import com.archimatetool.model.ITextAlignment;
import com.archimatetool.model.ITextPosition;

Expand Down Expand Up @@ -58,10 +59,11 @@ protected void drawFigure(Graphics graphics) {
setDisabledState(graphics);
}

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

setLineStyle(graphics);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, bounds);
setLineStyle(graphics);
}

graphics.setBackgroundColor(getFillColor());
graphics.setForegroundColor(getLineColor());
Expand Down Expand Up @@ -131,17 +133,21 @@ protected void drawFigure(Graphics graphics) {
drawIconImage(graphics, bounds);
}

graphics.setAlpha(getLineAlpha());
graphics.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + tabHeight);
graphics.drawLine(bounds.x, bounds.y, bounds.x + tabWidth, bounds.y);
graphics.drawLine(bounds.x + tabWidth, bounds.y, bounds.x + tabWidth, bounds.y + tabHeight);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + tabHeight);
graphics.drawLine(bounds.x, bounds.y, bounds.x + tabWidth, bounds.y);
graphics.drawLine(bounds.x + tabWidth, bounds.y, bounds.x + tabWidth, bounds.y + tabHeight);
}
}

disposeGradientPattern(graphics, gradient);

// Outlines
graphics.setAlpha(getLineAlpha());
graphics.drawPolygon(mainRectangle);
if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.drawPolygon(mainRectangle);
}

graphics.popState();

Expand Down
Loading

0 comments on commit 2e5b602

Please sign in to comment.