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

Set of improvments #92

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Logisim's user interface has numerous gotchas that need to be addressed. Here's
It is arguably the best free/libre and gratis tool for teaching circuit design.
That is why its development must continue.

## Newest GitHub build
If you just want to test the newest developer version to report issues or for new features, download it here.
[![Build Status](http://84.201.35.242:8080/job/LOGISIM/badge/icon)](http://mechtecs.tk:8080/job/LOGISIM/)
[Download](http://84.201.35.242:8080/job/LOGISIM/)
## Getting started for developers

The build script recognizes the following commands:
Expand Down
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'sonar-runner'

if (System.properties['os.name'].toLowerCase().contains('mac')) {
apply plugin: 'macAppBundle'

macAppBundle {
mainClassName = "com.cburch.logisim.Main"
icon = "LogisimApp.icns"
Expand Down Expand Up @@ -65,18 +65,14 @@ buildscript {

repositories {
mavenCentral()
maven {
url 'http://nexus.gephi.org/nexus/content/repositories/public'
}
}

dependencies {
compile \
'javax.help:javahelp:2.0.05',
'com.connectina.swing:fontchooser:1.0',
'net.sourceforge.collections:collections-generic:4.01',
'org.apache.xmlgraphics:batik-svggen:1.7',
'org.apache.xmlgraphics:batik-swing:1.7',
'org.apache.xmlgraphics:batik-swing:1.7',

// Native JDK logger (java.util.logging)
//'org.slf4j:slf4j-jdk14:1.7.5',
Expand Down Expand Up @@ -135,4 +131,3 @@ processResources << {
}
}
}

239 changes: 120 additions & 119 deletions src/main/java/com/cburch/draw/canvas/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,123 +17,124 @@

@SuppressWarnings("serial")
public class Canvas extends JComponent {
public static final String TOOL_PROPERTY = "tool";
public static final String MODEL_PROPERTY = "model";

private CanvasModel model;
private ActionDispatcher dispatcher;
private CanvasListener listener;
private Selection selection;

public Canvas() {
model = null;
listener = new CanvasListener(this);
selection = new Selection();

addMouseListener(listener);
addMouseMotionListener(listener);
addKeyListener(listener);
setPreferredSize(new Dimension(200, 200));
}

public CanvasModel getModel() {
return model;
}

public CanvasTool getTool() {
return listener.getTool();
}

public void toolGestureComplete(CanvasTool tool, CanvasObject created) {
// nothing to do - subclass may override
}

protected JPopupMenu showPopupMenu(MouseEvent e, CanvasObject clicked) {
// subclass will override if it supports popup menus
return null;
}

public Selection getSelection() {
return selection;
}

protected void setSelection(Selection value) {
selection = value;
repaint();
}

public void doAction(Action action) {
dispatcher.doAction(action);
}

public void setModel(CanvasModel value, ActionDispatcher dispatcher) {
CanvasModel oldValue = model;
if (!oldValue.equals(value)) {
if (oldValue != null) {
oldValue.removeCanvasModelListener(listener);
}

model = value;
this.dispatcher = dispatcher;
if (value != null) {
value.addCanvasModelListener(listener);
}

selection.clearSelected();
repaint();
firePropertyChange(MODEL_PROPERTY, oldValue, value);
}
}

public void setTool(CanvasTool value) {
CanvasTool oldValue = listener.getTool();
if (!value.equals(oldValue)) {
listener.setTool(value);
firePropertyChange(TOOL_PROPERTY, oldValue, value);
}
}

public void repaintCanvasCoords(int x, int y, int width, int height) {
repaint(x, y, width, height);
}

public double getZoomFactor() {
// subclass will have to override this
return 1.0;
}

public int snapX(int x) {
// subclass will have to override this
return x;
}

public int snapY(int y) {
// subclass will have to override this
return y;
}

@Override
public void paintComponent(Graphics g) {
paintBackground(g);
paintForeground(g);
}

protected void paintBackground(Graphics g) {
g.clearRect(0, 0, getWidth(), getHeight());
}

protected void paintForeground(Graphics g) {
CanvasModel cModel = this.model;
CanvasTool tool = listener.getTool();
if (cModel != null) {
Graphics dup = g.create();
cModel.paint(g, selection);
dup.dispose();
}
if (tool != null) {
Graphics dup = g.create();
tool.draw(this, dup);
dup.dispose();
}
}
public static final String TOOL_PROPERTY = "tool";
public static final String MODEL_PROPERTY = "model";

private CanvasModel model;
private ActionDispatcher dispatcher;
private CanvasListener listener;
private Selection selection;

public Canvas() {
model = null;
listener = new CanvasListener(this);
selection = new Selection();

addMouseListener(listener);
addMouseMotionListener(listener);
addKeyListener(listener);
setPreferredSize(new Dimension(200, 200));
}

public CanvasModel getModel() {
return model;
}

public CanvasTool getTool() {
return listener.getTool();
}

public void toolGestureComplete(CanvasTool tool, CanvasObject created) {
// nothing to do - subclass may override
}

protected JPopupMenu showPopupMenu(MouseEvent e, CanvasObject clicked) {
// subclass will override if it supports popup menus
return null;
}

public Selection getSelection() {
return selection;
}

protected void setSelection(Selection value) {
selection = value;
repaint();
}

public void doAction(Action action) {
dispatcher.doAction(action);
}

public void setModel(CanvasModel value, ActionDispatcher dispatcher) {
CanvasModel oldValue = model;
if (oldValue != null) {
if (!oldValue.equals(value)) {
oldValue.removeCanvasModelListener(listener);
}
}
model = value;
this.dispatcher = dispatcher;
if (value != null) {
value.addCanvasModelListener(listener);
}

selection.clearSelected();
repaint();

if (oldValue == null)
firePropertyChange(MODEL_PROPERTY, oldValue, value);
}

public void setTool(CanvasTool value) {
CanvasTool oldValue = listener.getTool();
if (!value.equals(oldValue)) {
listener.setTool(value);
firePropertyChange(TOOL_PROPERTY, oldValue, value);
}
}

public void repaintCanvasCoords(int x, int y, int width, int height) {
repaint(x, y, width, height);
}

public double getZoomFactor() {
// subclass will have to override this
return 1.0;
}

public int snapX(int x) {
// subclass will have to override this
return x;
}

public int snapY(int y) {
// subclass will have to override this
return y;
}

@Override
public void paintComponent(Graphics g) {
paintBackground(g);
paintForeground(g);
}

protected void paintBackground(Graphics g) {
g.clearRect(0, 0, getWidth(), getHeight());
}

protected void paintForeground(Graphics g) {
CanvasModel cModel = this.model;
CanvasTool tool = listener.getTool();
if (cModel != null) {
Graphics dup = g.create();
cModel.paint(g, selection);
dup.dispose();
}
if (tool != null) {
Graphics dup = g.create();
tool.draw(this, dup);
dup.dispose();
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/logisim/circuit/Wire.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public final class Wire implements Component, AttributeSet, CustomHandles,
Iterable<Location> {
/** Stroke width when drawing wires. */
public static final int WIDTH = 1;
public static final int WIDTH = 3;

public static final AttributeOption VALUE_HORZ
= new AttributeOption("horz", getFromLocale("wireDirectionHorzOption"));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cburch/logisim/std/arith/Arithmetic.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Arithmetic extends Library {
"bitadder.svg", "BitAdder"),
new FactoryDescription("BitFinder", getFromLocale("bitFinderComponent"),
"bitfindr.svg", "BitFinder"),
new FactoryDescription("Pow", getFromLocale("powComponent"),
"pow.svg", "Pow"),
};

private List<Tool> tools = null;
Expand Down
Loading