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

Rs05 #60

Closed
wants to merge 10 commits into from
Closed

Rs05 #60

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
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ repositories {
maven {
url 'http://nexus.gephi.org/nexus/content/repositories/public'
}
maven {
url 'https://raw.githubusercontent.com/gephi/gephi/mvn-thirdparty-repo/'
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ else if (val.equals(ProtoValue.UNKNOWN)) {
painter.drawPorts();
}


@Override
public void propagate(InstanceState state) {
Value val = state.getPort(0); // the val of the signal, receive the voltage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,31 @@ public void paintInstance(InstancePainter painter) {
g.fillRect(x, y-2, 6, 4);
g.fillRect(x+34, y-2, 6, 4);

paintShortCircuit(painter);

painter.drawPorts();
}

public void paintShortCircuit(InstancePainter painter) {
Location loc = painter.getLocation();
int x = loc.getX();
int y = loc.getY();
Graphics g = painter.getGraphics();

int offx = 15;
int offy = -5;

g.setColor(Color.red);
g.fillPolygon(new int[]{x - 10 + offx, x + 20 + offx , x + 18 + offx, x - 12 + offx},
new int[]{y + 20 + offy, y - 10 + offy, y - 12 + offy, y + 18 + offy}, 4);
g.setColor(Color.yellow);
g.fillPolygon(new int[]{x + 8 + offx, x - 4 + offx, x + 5 + offx, x + 2 + offx, x + 14 + offx, x + 5 + offx},
new int[]{y - 10 + offy, y + 8 + offy, y + 5 + offy, y + 20 + offy, y + 2 + offy, y + 3 + offy}, 6);
g.setColor(Color.black);
g.drawPolygon(new int[]{x + 8 + offx, x - 4 + offx , x + 5 + offx, x + 2 + offx, x + 14 + offx, x + 5 + offx},
new int[]{y - 10 + offy, y + 8 + offy, y + 5 + offy, y + 20 + offy, y + 2 + offy, y + 3 + offy}, 6);
}

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
return Bounds.create(0, -5, 40, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import com.cburch.logisim.proj.Project;
import com.cburch.logisim.proj.ProjectEvent;
import com.cburch.logisim.proj.ProjectListener;
import com.cburch.logisim.tools.ExecuteTool;
import com.cburch.logisim.tools.PokeTool;
import com.cburch.logisim.tools.SimulateTool;
import com.cburch.logisim.tools.Tool;
import com.cburch.logisim.util.InputEventUtil;

Expand Down Expand Up @@ -204,6 +207,11 @@ private void buildContents() {
List<ToolbarItem> newItems = new ArrayList<ToolbarItem>();
int pos = -1;
ToolbarData data = proj.getLogisimFile().getOptions().getToolbarData();

// We add simulate and execute buttons
data.addTool(new SimulateTool());
data.addTool(new ExecuteTool());

for (Tool tool : data.getContents()) {
++pos;
if (tool == null) {
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/com/cburch/logisim/tools/ExecuteTool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.cburch.logisim.tools;

import com.cburch.logisim.comp.ComponentDrawContext;
import com.cburch.logisim.util.Icons;

import javax.swing.*;
import java.awt.*;

public class ExecuteTool extends Tool {

private static final Icon toolIcon = Icons.getIcon("execute.svg");

public ExecuteTool() {

}

@Override
public String getName() {
return "Execute tool";
}

@Override
public String getDisplayName() {
return "executeTool";
}

@Override
public String getDescription() {
return "Execute Circuit";
}

@Override
public void paintIcon(ComponentDrawContext c, int x, int y) {
Graphics g = c.getGraphics();
if (toolIcon != null) {
toolIcon.paintIcon(c.getDestination(), g, x + 2, y + 2);
} else {
g.setColor(java.awt.Color.black);
/*
* The code below It's only executed if the icon is not available.
*/

}
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/cburch/logisim/tools/SimulateTool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.cburch.logisim.tools;

import com.cburch.logisim.comp.ComponentDrawContext;
import com.cburch.logisim.util.Icons;

import javax.swing.*;
import java.awt.*;

public class SimulateTool extends Tool {

private static final Icon toolIcon = Icons.getIcon("simulate.svg");

@Override
public String getName() {
return "Simulate tool";
}

@Override
public String getDisplayName() {
return "simulateTool";
}

@Override
public String getDescription() {
return "Simulate Circuit";
}

@Override
public void paintIcon(ComponentDrawContext c, int x, int y) {
Graphics g = c.getGraphics();
if (toolIcon != null) {
toolIcon.paintIcon(c.getDestination(), g, x + 2, y + 2);
} else {
g.setColor(java.awt.Color.black);
/*
* The code below It's only executed if the icon is not available.
*/

}
}
}
67 changes: 67 additions & 0 deletions src/main/resources/logisim/icons/execute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions src/main/resources/logisim/icons/simulate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.