Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Feedback shadow for remaining figures #704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CircuitBorder extends AbstractBorder {
protected static Insets insets = new Insets(16, 12, 16, 12);
protected static PointList connector = new PointList();
protected static PointList bottomConnector = new PointList();
private static final int CORNER_RADIUS = 6;
protected static final int CORNER_RADIUS = 6;

static {
connector.addPoint(-4, 0);
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 static org.eclipse.gef.examples.logicdesigner.figures.CircuitBorder.CORNER_RADIUS;

Check warning on line 15 in org.eclipse.gef.examples.logic/src/org/eclipse/gef/examples/logicdesigner/figures/CircuitFeedbackBorder.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Insets;
Expand All @@ -29,47 +30,34 @@

// Draw the connectors
connector.translate(x1, rec.y);
g.fillPolygon(connector);
g.drawPolygon(connector);
connector.translate(-x1, -rec.y);
g.drawLine(x1 - 2, rec.bottom() - 3, x1 + 3, rec.bottom() - 3);
bottomConnector.translate(x1, rec.bottom());
g.fillPolygon(bottomConnector);
g.drawPolygon(bottomConnector);
bottomConnector.translate(-x1, -rec.bottom());
}
}

@Override
public void paint(IFigure figure, Graphics g, Insets in) {
g.setXORMode(true);
g.setForegroundColor(ColorConstants.white);
g.setBackgroundColor(LogicColorConstants.ghostFillColor);
g.setForegroundColor(LogicColorConstants.feedbackFill);
g.setBackgroundColor(LogicColorConstants.feedbackFill);

Rectangle r = figure.getBounds().getShrinked(in);

// Draw the sides of the border
g.fillRectangle(r.x, r.y + 2, r.width, 6);
g.fillRectangle(r.x, r.bottom() - 8, r.width, 6);
g.fillRectangle(r.x, r.y + 2, 6, r.height - 4);
g.fillRectangle(r.right() - 6, r.y + 2, 6, r.height - 4);

g.fillRectangle(r.x, r.y + 2, 6, 6);
g.fillRectangle(r.x, r.bottom() - 8, 6, 6);
g.fillRectangle(r.right() - 6, r.y + 2, 6, 6);
g.fillRectangle(r.right() - 6, r.bottom() - 8, 6, 6);
// Draw top and bottom
Rectangle topBorder = new Rectangle(r.x, r.y + 4, r.width, 12);
g.fillRoundRectangle(topBorder, CORNER_RADIUS * 2, CORNER_RADIUS * 2);
Rectangle bottomBorder = new Rectangle(r.x, r.bottom() - 16, r.width, 12);
g.fillRoundRectangle(bottomBorder, CORNER_RADIUS * 2, CORNER_RADIUS * 2);

// Outline the border
g.drawPoint(r.x, r.y + 2);
g.drawPoint(r.x, r.bottom() - 3);
g.drawPoint(r.right() - 1, r.y + 2);
g.drawPoint(r.right() - 1, r.bottom() - 3);
g.drawLine(r.x, r.y + 2, r.right() - 1, r.y + 2);
g.drawLine(r.x, r.bottom() - 3, r.right() - 1, r.bottom() - 3);
g.drawLine(r.x, r.y + 2, r.x, r.bottom() - 3);
g.drawLine(r.right() - 1, r.bottom() - 3, r.right() - 1, r.y + 2);
// Draw left and right side
g.fillRectangle(r.x, r.y + 4 + CORNER_RADIUS, 8, r.height - 8 - CORNER_RADIUS * 2);
g.fillRectangle(r.right() - 8, r.y + 4 + CORNER_RADIUS, 8, r.height - 8 - CORNER_RADIUS * 2);

r.shrink(new Insets(1, 1, 0, 0));
r.expand(1, 1);
r.shrink(getInsets(figure));
drawConnectors(g, figure.getBounds().getShrinked(in));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class CircuitFeedbackFigure extends RectangleFigure {

public CircuitFeedbackFigure() {
this.setFill(false);
this.setXOR(true);
setBorder(new CircuitFeedbackBorder());
}

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,21 +24,25 @@ public class GroundFeedbackFigure extends GroundFigure {
*/
@Override
protected void paintFigure(Graphics g) {
g.setXORMode(true);
g.setForegroundColor(ColorConstants.white);
g.setBackgroundColor(LogicColorConstants.ghostFillColor);
Rectangle r = getBounds().getCopy();

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

r.x += 1;
r.y += 1;
r.width -= 2;
r.height -= 2;

g.fillOval(r);
r.height--;
r.width--;
g.drawOval(r);
g.translate(r.getLocation());

// Draw the "V"
g.drawLine(6, 8, 10, 18);
g.drawLine(10, 18, 14, 8);
g.drawLine(10, 16, 10, 18);

// Draw the "0"
g.drawOval(14, 16, 6, 6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.gef.examples.logicdesigner.figures;

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

Expand All @@ -23,42 +22,32 @@ public class LEDFeedbackFigure extends LEDFigure {
*/
@Override
protected void paintFigure(Graphics g) {
g.setXORMode(true);
g.setForegroundColor(ColorConstants.white);
g.setBackgroundColor(LogicColorConstants.feedbackOutline);

Rectangle r = getBounds().getCopy();
g.translate(r.getLocation());

g.setBackgroundColor(LogicColorConstants.ghostFillColor);
g.fillRectangle(0, 4, r.width, r.height - 8);
Rectangle mainBody = new Rectangle(0, 2, r.width, r.height - 4);
g.fillRoundRectangle(mainBody, CORNER_RADIUS, CORNER_RADIUS);
drawConnectors(g, r);

int right = r.width - 1;
g.drawLine(0, Y1, right, Y1);
g.drawLine(0, Y1, 0, Y2);
g.drawLine(0, Y2, right, Y2);
g.drawLine(right, Y1, right, Y2);
// Draw display
g.setBackgroundColor(LogicColorConstants.feedbackFill);
g.fillRoundRectangle(displayRectangle, CORNER_RADIUS, CORNER_RADIUS);

g.drawPoint(0, Y1);
g.drawPoint(right, Y1);
g.drawPoint(0, Y2);
g.drawPoint(right, Y2);
}

// Draw the gaps for the connectors
private static void drawConnectors(Graphics g, Rectangle r) {
for (int i = 0; i < 4; i++) {
g.drawLine(GAP_CENTERS_X[i] - 4, Y1, GAP_CENTERS_X[i] + 6, Y1);
g.drawLine(GAP_CENTERS_X[i] - 4, Y2, GAP_CENTERS_X[i] + 6, Y2);
}

// Draw the connectors
for (int i = 0; i < 4; i++) {
connector.translate(GAP_CENTERS_X[i], 0);
g.drawPolygon(connector);
g.fillPolygon(connector);
connector.translate(-GAP_CENTERS_X[i], 0);

bottomConnector.translate(GAP_CENTERS_X[i], r.height - 1);
g.drawPolygon(bottomConnector);
bottomConnector.translate(-GAP_CENTERS_X[i], -r.height + 1);
g.fillPolygon(bottomConnector);
bottomConnector.translate(-GAP_CENTERS_X[i], -(r.height - 1));
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class LEDFigure extends NodeFigure implements HandleBounds {
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;
protected static final int CORNER_RADIUS = 6;

static {
connector.addPoint(-3, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.gef.examples.logicdesigner.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
Expand All @@ -26,9 +25,8 @@ public class LabelFeedbackFigure extends BentCornerFigure {
protected void paintFigure(Graphics graphics) {
Rectangle rect = getBounds().getCopy();

graphics.setXORMode(true);
graphics.setForegroundColor(ColorConstants.white);
graphics.setBackgroundColor(LogicColorConstants.ghostFillColor);
graphics.setBackgroundColor(LogicColorConstants.feedbackFill);
graphics.setForegroundColor(LogicColorConstants.feedbackOutline);

graphics.translate(getLocation());

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,12 +24,17 @@ public class LiveOutputFeedbackFigure extends LiveOutputFigure {
*/
@Override
protected void paintFigure(Graphics g) {
g.setXORMode(true);
g.setForegroundColor(ColorConstants.white);
Rectangle r = getBounds().getCopy();

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

Rectangle r = getBounds().getCopy();
r.x += 1;
r.y += 1;
r.width -= 2;
r.height -= 2;

g.fillOval(r);
r.height--;
Expand All @@ -39,12 +45,10 @@ protected void paintFigure(Graphics g) {
// Draw the "V"
g.drawLine(6, 8, 10, 18);
g.drawLine(10, 18, 14, 8);
g.drawLine(10, 16, 10, 18);

// Draw the "+"
g.drawLine(18, 14, 18, 22);
g.drawLine(14, 18, 22, 18);
g.drawPoint(18, 18);
}

}
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,6 @@
*******************************************************************************/
package org.eclipse.gef.examples.logicdesigner.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Insets;
Expand All @@ -29,9 +28,8 @@ public LogicFlowFeedbackBorder(int width) {

@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
graphics.setForegroundColor(ColorConstants.white);
graphics.setBackgroundColor(LogicColorConstants.ghostFillColor);
graphics.setXORMode(true);
graphics.setBackgroundColor(LogicColorConstants.feedbackFill);
graphics.setForegroundColor(LogicColorConstants.feedbackOutline);

Rectangle r = figure.getBounds();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class LogicFlowFeedbackFigure extends RectangleFigure {

public LogicFlowFeedbackFigure() {
this.setFill(false);
this.setXOR(true);
setBorder(new LogicFlowFeedbackBorder());
}

Expand Down
Loading