Skip to content

Commit

Permalink
Add AbstractDiagramModelObjectFigure#getLineWidth convenience method
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillipus committed Aug 20, 2023
1 parent bda642a commit 4d8422f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected void paintFigure(Graphics graphics) {
if(getBorderColor() != null) {
graphics.setAlpha(getLineAlpha());

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

graphics.setForegroundColor(ColorFactory.getLighterColor(getBorderColor(), 0.82f));
Path path = new Path(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void drawFigure(Graphics graphics) {
* @param bounds The bounds of the object
*/
protected void setLineWidth(Graphics graphics, Rectangle bounds) {
setLineWidth(graphics, getDiagramModelObject().getLineWidth(), bounds);
setLineWidth(graphics, getLineWidth(), bounds);
}

/**
Expand Down Expand Up @@ -257,6 +257,10 @@ protected int getGradient() {
return fDiagramModelObject.getGradient();
}

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

@Override
public void updateIconImage() {
if(getIconicDelegate() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ protected void setDisabledState(Graphics graphics) {
getOwner().setDisabledState(graphics);
}

/**
* @return The owner's line width
*/
protected int getLineWidth() {
return getOwner().getLineWidth();
}

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected void drawFigure(Graphics graphics) {
setDisabledState(graphics);
}

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

// Main Fill
graphics.setBackgroundColor(getFillColor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void drawFigure(Graphics graphics) {
float y1 = bounds.y + (bounds.height / 5);
float y2 = bounds.y + bounds.height - (bounds.height / 5);

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

path.moveTo(bounds.x, y1);
path.lineTo(x1, y1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void drawFigure(Graphics graphics) {
setDisabledState(graphics);
}

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

// Main Fill
graphics.setBackgroundColor(getFillColor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void paintFigure(Graphics graphics) {
graphics.setAntialias(SWT.ON);
Rectangle bounds = getBounds().getCopy();

graphics.setLineWidth(getDiagramModelObject().getLineWidth() + 1);
graphics.setLineWidth(getLineWidth() + 1);

bounds.height -= getLabel().getPreferredSize().height;

Expand Down

0 comments on commit 4d8422f

Please sign in to comment.