Skip to content

Commit

Permalink
Reduce LED figure size and optimize display proportions (#699)
Browse files Browse the repository at this point in the history
* Reduce LED figure size and optimize display proportions
* Fix test failures for testWithGrid and testWithSnapToGrid

Signed-off-by: Amadeus1791 <[email protected]>
  • Loading branch information
Amadeus1791 authored Feb 21, 2025
1 parent c6f10c0 commit 8ee59da
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,37 @@
*/
public class LEDFigure extends NodeFigure implements HandleBounds {

public static final Dimension SIZE = new Dimension(122, 94);
protected static final Font DISPLAY_FONT = new Font(null, "DialogInput", 23, SWT.NORMAL); //$NON-NLS-1$
public static final Dimension SIZE = new Dimension(92, 71);
protected static final Font DISPLAY_FONT = new Font(null, "DialogInput", 24, SWT.NORMAL); //$NON-NLS-1$
protected static PointList connector = new PointList();
protected static PointList bottomConnector = new PointList();
protected static Rectangle displayRectangle = new Rectangle(30, 22, 62, 50);
protected static Rectangle displayShadow = new Rectangle(28, 20, 64, 52);
protected static Rectangle displayHighlight = new Rectangle(30, 22, 64, 52);
protected static Point valuePoint = new Point(32, 20);
protected static Rectangle displayRectangle = new Rectangle(14, 17, 65, 38);
protected static Rectangle displayShadow = new Rectangle(12, 15, 66, 39);
protected static Rectangle displayHighlight = new Rectangle(14, 17, 66, 39);
protected static Point valuePoint = new Point(24, 15);
private static final int HORIZONTAL_PADDING = 3;
private static final int VERTICAL_OFFSET = -1;
private static final int CORNER_RADIUS = 6;

static {
connector.addPoint(-4, 0);
connector.addPoint(-3, 0);
connector.addPoint(2, 0);
connector.addPoint(4, 2);
connector.addPoint(4, 10);
connector.addPoint(-2, 10);
connector.addPoint(-2, 2);
connector.addPoint(3, 2);
connector.addPoint(3, 8);
connector.addPoint(-1, 8);
connector.addPoint(-1, 2);

bottomConnector.addPoint(-4, 0);
bottomConnector.addPoint(-3, 0);
bottomConnector.addPoint(2, 0);
bottomConnector.addPoint(4, -2);
bottomConnector.addPoint(4, -10);
bottomConnector.addPoint(-2, -10);
bottomConnector.addPoint(-2, -2);
bottomConnector.addPoint(3, -1);
bottomConnector.addPoint(3, -7);
bottomConnector.addPoint(-1, -7);
bottomConnector.addPoint(-1, -1);
}

protected static final int[] GAP_CENTERS_X = { 16, 46, 76, 106 };
protected static final int Y1 = 4;
protected static final int Y2 = 88;
protected static final int[] GAP_CENTERS_X = { 12, 35, 57, 80 };
protected static final int Y1 = 3;
protected static final int Y2 = 66;

protected String value;

Expand All @@ -74,38 +74,38 @@ public class LEDFigure extends NodeFigure implements HandleBounds {
public LEDFigure() {
FixedConnectionAnchor c;
c = new FixedConnectionAnchor(this);
c.offsetH = 102;
c.offsetH = 77;
connectionAnchors.put(LED.TERMINAL_1_IN, c);
inputConnectionAnchors.add(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 72;
c.offsetH = 54;
connectionAnchors.put(LED.TERMINAL_2_IN, c);
inputConnectionAnchors.add(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 42;
c.offsetH = 32;
connectionAnchors.put(LED.TERMINAL_3_IN, c);
inputConnectionAnchors.add(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 12;
c.offsetH = 9;
connectionAnchors.put(LED.TERMINAL_4_IN, c);
inputConnectionAnchors.add(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 102;
c.offsetH = 77;
c.topDown = false;
connectionAnchors.put(LED.TERMINAL_1_OUT, c);
outputConnectionAnchors.add(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 72;
c.offsetH = 54;
c.topDown = false;
connectionAnchors.put(LED.TERMINAL_2_OUT, c);
outputConnectionAnchors.add(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 42;
c.offsetH = 32;
c.topDown = false;
connectionAnchors.put(LED.TERMINAL_3_OUT, c);
outputConnectionAnchors.add(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 12;
c.offsetH = 9;
c.topDown = false;
connectionAnchors.put(LED.TERMINAL_4_OUT, c);
outputConnectionAnchors.add(c);
Expand All @@ -117,7 +117,7 @@ public LEDFigure() {
*/
@Override
public Rectangle getHandleBounds() {
return getBounds().getShrinked(new Insets(4, 0, 4, 0));
return getBounds().getShrinked(new Insets(3, 0, 3, 0));
}

/**
Expand Down Expand Up @@ -156,8 +156,6 @@ private static void drawConnectors(Graphics g, Rectangle r) {
for (int i = 0; i < 4; i++) {
// Draw the gaps for the connectors
g.setForegroundColor(ColorConstants.listBackground);
g.drawLine(GAP_CENTERS_X[i] - 2, Y1, GAP_CENTERS_X[i] + 3, Y1);
g.drawLine(GAP_CENTERS_X[i] - 2, Y2, GAP_CENTERS_X[i] + 3, Y2);

// Draw the connectors
g.setForegroundColor(LogicColorConstants.connectorGreen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class LED extends LogicSubpart {

static final long serialVersionUID = 1;

private static final Dimension DEFAULT_SIZE = new Dimension(122, 94);
private static final Dimension DEFAULT_SIZE = new Dimension(92, 71);

private static final Image LED_ICON = createImage(LED.class, "icons/ledicon16.gif"); //$NON-NLS-1$
private static int count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void testWithGrid() {
forceUpdate(editor.getSWTBotGefViewer());
});

assertEquals(figure.getLocation(), new Point(12, 20), "Part is not on grid line");
assertEquals(figure.getLocation(), new Point(12, 21), "Part is not on grid line");
}

/**
Expand All @@ -124,7 +124,7 @@ public void testWithSnapToGrid() {

SWTBotGefEditor editor = bot.gefEditor("emptyModel1.logic");
editor.activateTool("LED");
editor.click(50, 48);
editor.click(50, 49);

editor.activateTool("Label");
editor.click(200, 200);
Expand Down

0 comments on commit 8ee59da

Please sign in to comment.