Skip to content

Commit

Permalink
Updated Feedback shadow for Logic Gates
Browse files Browse the repository at this point in the history
Signed-off-by: Amadeus1791 <[email protected]>
  • Loading branch information
Sezuan01 committed Mar 2, 2025
1 parent 79ce421 commit 5d43846
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*******************************************************************************/
package org.eclipse.gef.examples.logicdesigner.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.SWT;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;

Expand All @@ -23,48 +24,37 @@ public class AndGateFeedbackFigure extends AndGateFigure {
*/
@Override
protected void paintFigure(Graphics g) {
g.setXORMode(true);
g.setForegroundColor(ColorConstants.white);
g.setBackgroundColor(LogicColorConstants.ghostFillColor);
g.setBackgroundColor(LogicColorConstants.feedbackFill);
g.setForegroundColor(LogicColorConstants.feedbackOutline);
g.setAntialias(SWT.ON);
g.setLineWidth(2);

Rectangle r = getBounds().getCopy();
r.translate(4, 4);
r.translate(4, 5);
r.setSize(22, 18);

// Draw terminals, 2 at top
g.drawLine(r.x + 4, r.y, r.x + 4, r.y - 4);
g.drawLine(r.right() - 6, r.y, r.right() - 6, r.y - 4);
g.drawPoint(r.x + 4, r.y);
g.drawPoint(r.right() - 6, r.y);

// outline main area
g.drawLine(r.x, r.y, r.right() - 1, r.y);
g.drawLine(r.right() - 1, r.y, r.right() - 1, r.bottom() - 1);
g.drawLine(r.x, r.y, r.x, r.bottom() - 1);
g.drawLine(r.x + 4, r.y, r.x + 4, r.y - 6);
g.drawLine(r.right() - 5, r.y, r.right() - 5, r.y - 5);

g.drawPoint(r.x, r.y);
g.drawPoint(r.right() - 1, r.y);
// draw main area
r.width++;
r.height++;
g.fillRoundRectangle(r, 5, 5);

g.fillRectangle(r);
// outline main area
Rectangle outlineRect = r.getCopy();
outlineRect.width--;
g.drawRoundRectangle(outlineRect, 5, 5);

// draw and outline the arc
r.height = 18;
r.y += 8;
g.setForegroundColor(LogicColorConstants.ghostFillColor);
g.drawLine(r.x, r.y + 8, r.x + 20, r.y + 8);
g.setForegroundColor(ColorConstants.white);

g.drawPoint(r.x, r.y + 8);

r.y += 7;
g.fillArc(r, 180, 180);

r.width--;
r.height--;

g.drawArc(r, 180, 180);
g.drawLine(r.x + r.width / 2, r.bottom(), r.x + r.width / 2, r.bottom() + 4);

g.drawPoint(r.x + r.width / 2, r.bottom());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ public interface LogicColorConstants {
public final static Color logicBackgroundBlue = new Color(200, 200, 240);
public final static Color ghostFillColor = new Color(31, 31, 31);
public static final Color displayTextLED = new Color(255, 187, 51);
public final static Color feedbackFill = new Color(120, 120, 120);
public final static Color feedbackOutline = new Color(70, 70, 70);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*******************************************************************************/
package org.eclipse.gef.examples.logicdesigner.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.SWT;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;

Expand All @@ -23,9 +24,10 @@ public class OrGateFeedbackFigure extends OrGateFigure {
*/
@Override
protected void paintFigure(Graphics g) {
g.setXORMode(true);
g.setForegroundColor(ColorConstants.white);
g.setBackgroundColor(LogicColorConstants.ghostFillColor);
g.setBackgroundColor(LogicColorConstants.feedbackFill);
g.setForegroundColor(LogicColorConstants.feedbackOutline);
g.setAntialias(SWT.ON);
g.setLineWidth(2);

Rectangle r = getBounds().getCopy();
r.translate(4, 4);
Expand All @@ -35,28 +37,21 @@ protected void paintFigure(Graphics g) {
g.drawLine(r.x + 4, r.y + 4, r.x + 4, r.y - 4);
g.drawLine(r.right() - 6, r.y + 4, r.right() - 6, r.y - 4);

// fix it
g.drawPoint(r.x + 4, r.y + 4);
g.drawPoint(r.right() - 6, r.y + 4);

// Draw the bottom arc of the gate
r.y += 8;

r.width--;
r.height--;
g.fillArc(r, 180, 180);
g.fillOval(r);
r.width--;
r.height--;
g.drawPoint(r.x, r.y + 8);

g.drawArc(r, 180, 180);
g.drawOval(r);
g.drawLine(r.x + r.width / 2, r.bottom(), r.x + r.width / 2, r.bottom() + 4);
g.drawPoint(r.x + r.width / 2, r.bottom());

// draw gate
g.translate(getLocation());
g.drawPolyline(GATE_OUTLINE);
g.fillPolygon(GATE_OUTLINE);
g.drawPolyline(GATE_OUTLINE);
g.translate(getLocation().getNegated());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*******************************************************************************/
package org.eclipse.gef.examples.logicdesigner.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.SWT;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;

Expand All @@ -23,9 +24,12 @@ public class XOrGateFeedbackFigure extends XOrGateFigure {
*/
@Override
protected void paintFigure(Graphics g) {
g.setXORMode(true);
g.setForegroundColor(ColorConstants.white);
g.setBackgroundColor(LogicColorConstants.ghostFillColor);

g.setBackgroundColor(LogicColorConstants.feedbackFill);
g.setForegroundColor(LogicColorConstants.feedbackOutline);
g.setAntialias(SWT.ON);
g.setLineWidth(2);

Rectangle r = getBounds().getCopy();
r.translate(4, 4);
r.setSize(22, 18);
Expand All @@ -46,20 +50,19 @@ protected void paintFigure(Graphics g) {
* top arc of the gate, so this region is clipped.
*/
g.pushState();
r.y++;
g.clipRect(r);
r.y--;

Rectangle clipRect = r.getCopy();
clipRect.x -= 2;
clipRect.width += 2;
clipRect.y = r.y + 6;
g.clipRect(clipRect);
r.width--;
r.height--;
g.fillArc(r, 180, 180);

g.fillOval(r);
r.width--;
r.height--;
g.drawArc(r, 180, 180);
g.drawPoint(r.x, r.y + 8);
g.drawOval(r);
g.popState();
g.drawLine(r.x + r.width / 2, r.bottom(), r.x + r.width / 2, r.bottom() + 4);
g.drawPoint(r.x + r.width / 2, r.bottom());

// Draw the gate outline and top curve
g.translate(getLocation());
Expand Down

0 comments on commit 5d43846

Please sign in to comment.