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

Redo feature #52

Merged
merged 31 commits into from
Jan 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c1c4a34
Added Batik to the project dependencies.
mikespallino Sep 25, 2013
c9ef0c4
Added svg swing component.
mikespallino Sep 25, 2013
042a3f0
Added documentation to Startup.parseArgs
steinmetzr Oct 1, 2013
9f74a69
Added gradle command for javadoc to readme.
steinmetzr Oct 1, 2013
094ab2d
added javadoc comments to com.cburch.logisim.LogisimVersion
steinmetzr Oct 4, 2013
ca0b56e
added documentation to com.cburch.logisim.LogisimVersion
steinmetzr Oct 7, 2013
cbf6c4a
Removed extra code for drawing the background
mikespallino Oct 8, 2013
08fb586
Made an example SVG file to use for the about credits.
mikespallino Oct 8, 2013
87cd6d7
Example SVG file.
mikespallino Oct 8, 2013
8fa96f8
Example SVG file.
mikespallino Oct 8, 2013
1430396
Removed useless hashCode method, cleaned up compareTo.
steinmetzr Oct 16, 2013
bac17a3
Why we work on this.
Oct 17, 2013
497794f
Merge remote-tracking branch 'steinmetzr/master'
Oct 17, 2013
2ab7d73
Merge remote-tracking branch 'nickbaldassare/master'
Oct 17, 2013
c0d41fe
deleted src/test/java/com.cburch.logisim.util
steinmetzr Oct 22, 2013
66e9faa
Converted all of the 104 icons to svg and changed the get calls to ge…
mikespallino Nov 13, 2013
21fe066
Default to left alignment.
steinmetzr Nov 13, 2013
92d68c1
Merge remote-tracking branch 'realbinglebob/master'
Nov 13, 2013
dbd9a54
Hard coded the size of the SVG Icons.
mikespallino Nov 13, 2013
06e3ccc
Merge remote-tracking branch 'realbinglebob/master'
Nov 13, 2013
ecf5be4
Added Sonar Runner to Logisim build script.
Dec 2, 2013
099025e
delete
steinmetzr Dec 10, 2013
79ad540
*Implemented redo feature.
allevaton Dec 11, 2013
f69f1b2
fixed little things in the readme
allevaton Jan 23, 2014
da646e6
Fixed broken CSS.
Jan 23, 2014
8f8537d
Merge branch 'master' of https://github.com/nickbaldassare/logisim in…
allevaton Jan 23, 2014
b253d16
Revert "delete"
allevaton Jan 23, 2014
5b9ccde
Merge branch 'readme'
allevaton Jan 23, 2014
e76a539
Large cleanup from Sonar
allevaton Jan 25, 2014
1db4188
Merge branch 'master' of https://github.com/lawrancej/logisim into pull
allevaton Jan 25, 2014
1bdfcab
Updated gitignore to ignore `*.class` files.
allevaton Jan 25, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .externalToolBuilders/Launch4j.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="C:\Program Files (x86)\Launch4j\launch4j.exe"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build
.gradle
.project
.classpath
*sonar*.properties
.sonar
.settings
bin
/nbproject/private/
*.class
/nbproject/private/
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# README

Logisim is a circuit simulator, [available here](http://ozark.hendrix.edu/~burch/logisim/).
Logisim is a circuit simulator, [originally available here](http://ozark.hendrix.edu/~burch/logisim/).

## Why this fork of Logisim?
Carl Burch, the original author of Logisim, abandoned development in 2011 and moved on to a similar successor project, [Toves](http://www.toves.org/) in 2013, because Logisim's code base is in need of a major overhaul. Rather than start from scratch ([something you should never do](http://www.joelonsoftware.com/articles/fog0000000069.html)), this fork of Logisim picks up where Dr. Burch left off to incrementally improve Logisim.

## What's wrong with Logisim?
Logisim's code itself has numerous smells. Here's an incomplete list of these:

* No test suite!
* Undocumented packages, classes, methods
* Duplicated and dead code
* No coherent organization (it should be MVC)
* High coupling, low cohesion (it would benefit from IoC)
* Unnecessarily reimplements functionality found in standard or third party libraries (e.g., it has it's own Toolbar classes)
* Code to draw components is too low-level

Logisim's user interface has numerous gotchas that need to be addressed. Here's some of the more important issues:

* The file format is not merge-friendly, making it impossible for students to collaborate on circuits
* Unreasonable defaults
* Limited interaction styles
* Single (graphical) view of circuit

## What's right with Logisim?
It is arguably the best free tool for teaching circuit design, which is why its development must continue.

## Getting started for developers
Logisim developers: Logisim uses the [Gradle build system](http://www.gradle.org), so set that up first before attempting to develop Logisim. Ensure that the gradle executable is in the system path. To build the executable for Windows, you must install [launch4j](http://launch4j.sourceforge.net/) and ensure it is on the system path.
Logisim developers: Logisim uses the [Gradle build system](http://www.gradle.org), so set that up first before attempting to develop Logisim. Ensure that the gradle executable is in the system path. To build the executable for Windows, you must install [launch4j](http://launch4j.sourceforge.net/) and ensure it is in the system path.

The build script recognizes the following commands:

Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: 'launch4j'
apply plugin: 'sonar-runner'

mainClassName = "com.cburch.logisim.Main"
version = '2.7.2'
Expand Down Expand Up @@ -32,7 +33,7 @@ repositories {
}

dependencies {
compile 'javax.help:javahelp:2.0.05', 'com.connectina.swing:fontchooser:1.0', 'org.apache.commons:commons-lang3:3.1', 'net.sourceforge.collections:collections-generic:4.01', fileTree(dir: 'libs', include: '*.jar')
compile 'javax.help:javahelp:2.0.05', 'com.connectina.swing:fontchooser:1.0', 'org.apache.commons:commons-lang3:3.1', '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-transcoder:1.7', fileTree(dir: 'libs', include: '*.jar')
testCompile 'junit:junit:4.11'
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/draw/shapes/SvgReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private static Color getColor(String hue, String opacity) {
String repl = opacity.substring(0, comma) + "."
+ opacity.substring(comma + 1);
x = Double.parseDouble(repl);
} catch (Throwable t) {
} catch (NumberFormatException ex) {
throw e;
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/cburch/draw/toolbar/ToolbarButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import javax.swing.JComponent;

import org.apache.batik.swing.JSVGCanvas;

import com.cburch.logisim.util.GraphicsUtil;

class ToolbarButton extends JComponent implements MouseListener {
Expand Down Expand Up @@ -58,7 +60,7 @@ public void paintComponent(Graphics g) {

Graphics g2 = g.create();
g2.translate(BORDER, BORDER);
item.paintIcon(ToolbarButton.this, g2);
item.paintIcon(this, g2);
g2.dispose();

// draw selection indicator
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cburch/draw/toolbar/ToolbarItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

public interface ToolbarItem {
public boolean isSelectable();
public void paintIcon(Component destination, Graphics g);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/draw/tools/CurveTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public CurveTool(DrawingAttributeSet attrs) {

@Override
public Icon getIcon() {
return Icons.getIcon("drawcurv.gif");
return Icons.getIcon("drawcurv.svg");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/draw/tools/LineTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public LineTool(DrawingAttributeSet attrs) {

@Override
public Icon getIcon() {
return Icons.getIcon("drawline.gif");
return Icons.getIcon("drawline.svg");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/draw/tools/OvalTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public OvalTool(DrawingAttributeSet attrs) {

@Override
public Icon getIcon() {
return Icons.getIcon("drawoval.gif");
return Icons.getIcon("drawoval.svg");
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cburch/draw/tools/PolyTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public PolyTool(boolean closed, DrawingAttributeSet attrs) {
@Override
public Icon getIcon() {
if (closed) {
return Icons.getIcon("drawpoly.gif");
return Icons.getIcon("drawpoly.svg");
} else {
return Icons.getIcon("drawplin.gif");
return Icons.getIcon("drawplin.svg");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/draw/tools/RectangleTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public RectangleTool(DrawingAttributeSet attrs) {

@Override
public Icon getIcon() {
return Icons.getIcon("drawrect.gif");
return Icons.getIcon("drawrect.svg");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public RoundRectangleTool(DrawingAttributeSet attrs) {

@Override
public Icon getIcon() {
return Icons.getIcon("drawrrct.gif");
return Icons.getIcon("drawrrct.svg");
}

@Override
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/com/cburch/draw/tools/SVGIcon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.cburch.draw.tools;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.io.IOException;
import java.net.URL;

import javax.swing.Icon;

import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.DocumentLoader;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.svg.SVGDocument;

public class SVGIcon implements Icon {

String path;
GraphicsNode svgIcon = null;

public SVGIcon(String path) {
try {
this.path = (path.startsWith("/logisim/icons/")) ? path : "/logisim/icons/" + path; // Quick and dirty hack. We should probably use a path resolver.
URL url = SVGIcon.class.getResource(this.path);
String xmlParser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory df = new SAXSVGDocumentFactory(xmlParser);
SVGDocument doc = df.createSVGDocument(url.toString());
UserAgent userAgent = new UserAgentAdapter();
DocumentLoader loader = new DocumentLoader(userAgent);
BridgeContext ctx = new BridgeContext(userAgent, loader);
ctx.setDynamicState(BridgeContext.DYNAMIC);
GVTBuilder builder = new GVTBuilder();
this.svgIcon = builder.build(ctx, doc);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

@Override
public int getIconHeight() {
//return (int)svgIcon.getPrimitiveBounds().getHeight();
return 16;
}

@Override
public int getIconWidth() {
//return (int)svgIcon.getPrimitiveBounds().getWidth();
return 16;
}

private void paintSvgIcon(Graphics2D g, int x, int y, double scaleX, double scaleY) {
AffineTransform transform = new AffineTransform(scaleX, 0.0, 0.0, scaleY, x, y);
svgIcon.setTransform(transform);
svgIcon.paint(g);
}

@Override
public void paintIcon(Component arg0, Graphics g, int x, int y) {
/* Graphics2D g2 = (Graphics2D) g.create();
arg0.paint(getGraphics());
g.drawImage(canvas.createImage(canvas.getWidth(), canvas.getHeight()), x, y, arg0);*/
paintSvgIcon((Graphics2D)g,x,y,1,1);
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/draw/tools/SelectTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public SelectTool() {

@Override
public Icon getIcon() {
return Icons.getIcon("select.gif");
return Icons.getIcon("select.svg");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/draw/tools/TextTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public TextTool(DrawingAttributeSet attrs) {

@Override
public Icon getIcon() {
return Icons.getIcon("text.gif");
return Icons.getIcon("text.svg");
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/cburch/draw/undo/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ public abstract class Action {

public abstract String getName();

/** Redo
*/
public abstract void doIt();

/** Undo
*/
public abstract void undo();

public boolean shouldAppendTo(Action other) { return false; }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cburch/gray/GrayCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public GrayCounter() {
// These next two lines set it up so that the explorer window shows a
// customized icon representing the component type. This should be a
// 16x16 image.
URL url = getClass().getClassLoader().getResource("com/cburch/gray/counter.gif");
URL url = getClass().getClassLoader().getResource("com/cburch/gray/counter.svg");
if (url != null) setIcon(new ImageIcon(url));
}

Expand Down
Loading