Skip to content

Commit

Permalink
Set line width on figures
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillipus committed Aug 14, 2023
1 parent 35bd90c commit 89d99ec
Show file tree
Hide file tree
Showing 67 changed files with 254 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void drawFigure(Graphics graphics, Color background) {
bounds.height--;

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

graphics.setBackgroundColor(background);
graphics.fillRectangle(bounds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,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
int lineWidth = 1;
setLineWidth(graphics, lineWidth, bounds);
setLineWidth(graphics, bounds);

// Bug on Linux hi-res using Graphics.fillGradient()
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=568864
Expand All @@ -162,7 +161,7 @@ protected void paintFigure(Graphics graphics) {
if(getBorderColor() != null) {
graphics.setAlpha(getLineAlpha());

float lineOffset = (float)lineWidth / 2;
float lineOffset = (float)getDiagramModelObject().getLineWidth() / 2;

graphics.setForegroundColor(ColorFactory.getLighterColor(getBorderColor(), 0.82f));
Path path = new Path(null);
Expand Down
7 changes: 7 additions & 0 deletions com.archimatetool.editor/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@
id="iconColorSection"
tab="appearance.tab">
</propertySection>
<propertySection
afterSection="lineColorSection"
class="com.archimatetool.editor.propertysections.LineWidthSection"
filter="com.archimatetool.editor.propertysections.LineWidthSection$Filter"
id="lineWidthSection"
tab="appearance.tab">
</propertySection>
<propertySection
afterSection="iconColorSection"
class="com.archimatetool.editor.propertysections.GradientSection"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,24 @@ protected void drawFigure(Graphics graphics) {
}
}

/**
* Set the line width to that in the diagram model and compensate the figure bounds width and height for this line width and translate the graphics instance
* @param graphics The graphics instance
* @param bounds The bounds of the object
*/
protected void setLineWidth(Graphics graphics, Rectangle bounds) {
setLineWidth(graphics, getDiagramModelObject().getLineWidth(), bounds);
}

/**
* Set the line width and compensate the figure bounds width and height for this line width and translate the graphics instance
* @param graphics The graphics instance
* @param lineWidth The line width
* @param bounds The bounds of the object
*/
protected void setLineWidth(Graphics graphics, int lineWidth, Rectangle bounds) {
lineWidth = lineWidth < 1 ? 1 : lineWidth > 4 ? 4 : lineWidth;

graphics.setLineWidth(lineWidth);

final double scale = FigureUtils.getGraphicsScale(graphics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ protected void setDisabledState(Graphics graphics) {
getOwner().setDisabledState(graphics);
}

/**
* Set the line width to that in the diagram model and compensate the figure bounds width and height for this line width and translate the graphics instance
* @param graphics The graphics instance
* @param bounds The bounds of the object
*/
protected void setLineWidth(Graphics graphics, Rectangle bounds) {
getOwner().setLineWidth(graphics, bounds);
}

/**
* Set the line width and compensate the figure bounds width and height for this line width and translate the graphics instance
* @param graphics The graphics instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

// Line Width
setLineWidth(graphics, 1, bounds);
setLineWidth(graphics, bounds);

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,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
setLineWidth(graphics, 1, bounds);
setLineWidth(graphics, bounds);

if(fImage != null) {
// Faster but no transparency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected void drawFigure(Graphics graphics) {
bounds.height--;

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

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected void paintFigure(Graphics graphics) {

// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE) {
setLineWidth(graphics, 1, bounds);
setLineWidth(graphics, bounds);
}

// Fill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected void drawFigure(Graphics graphics) {
bounds.height--;

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

PointList points = new PointList();
points.addPoint(bounds.x + FLANGE, bounds.y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

if(!isEnabled()) {
setDisabledState(graphics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void drawFigure(Graphics graphics) {
rect.height--;

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

if(!isEnabled()) {
setDisabledState(graphics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect, 2/3.0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect, 1.5); // Should match 'diameter'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect, 1.24); // Should match '3.1 / 2.5' (values used in getRadius() and getCenter())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void drawFigure(Graphics graphics) {
rect.height--;

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

if(!isEnabled()) {
setDisabledState(graphics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ protected void drawFigure(Graphics graphics) {
bounds.height--;

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

graphics.setAlpha(getAlpha());

if(!isEnabled()) {
setDisabledState(graphics);
}

Path path = getFigurePath(8, bounds, (float)lineWidth / 2);
Path path = getFigurePath(8, bounds, (float)getDiagramModelObject().getLineWidth() / 2);

// Main Fill
graphics.setBackgroundColor(getFillColor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

int height_indent = bounds.height / 6;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

int indent = Math.min(bounds.height / 3, bounds.width / 3);
int centre_y = bounds.y + bounds.height / 2 - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void drawFigure(Graphics graphics) {
rect.height--;

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

if(!isEnabled()) {
setDisabledState(graphics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect, 5/3.0); // Should match 'widthFraction' formula

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void drawFigure(Graphics graphics) {
}

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

// Scale line dashes below 1.0
double scale = Math.min(FigureUtils.getGraphicsScale(graphics), 1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect, 1 / 0.86); // Should match 'FRACTION' defined in getFigurePath()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void paintFigure(Graphics graphics) {
break;

case IJunction.OR_JUNCTION_TYPE:
setLineWidth(graphics, 1, bounds);
setLineWidth(graphics, bounds);
graphics.setForegroundColor(getFillColor());
graphics.drawOval(bounds);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect, 10/9.0); // Should match 'figureHeight'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void drawFigure(Graphics graphics) {
Rectangle bounds = getBounds().getCopy();

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

// The following is a not so awful code to draw a cloud...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void drawFigure(Graphics graphics) {
bounds.height--;

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

graphics.setAlpha(getAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void drawFigure(Graphics graphics) {
Rectangle imageBounds = rect.getCopy();

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

setFigurePositionFromTextPosition(rect);

Expand Down
Loading

0 comments on commit 89d99ec

Please sign in to comment.