Skip to content

Commit

Permalink
Label and Text tools have now color attribute, added a warning messag…
Browse files Browse the repository at this point in the history
…e about retrocompatibility of the problem fixed in v2.11.1.2
  • Loading branch information
LogisimIt committed Nov 15, 2017
1 parent 12567fe commit 339dfe7
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 13 deletions.
Binary file modified Compiled/Logisim-Fork.exe
Binary file not shown.
Binary file modified Compiled/Logisim-Fork.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion Logisim-Fork/com/cburch/logisim/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.cburch.logisim.gui.start.Startup;

public class Main {
public static final LogisimVersion VERSION = LogisimVersion.get(2, 11, 2, 1, LogisimVersion.getVariantFromFile());
public static final LogisimVersion VERSION = LogisimVersion.get(2, 11, 2, 5, LogisimVersion.getVariantFromFile());

public static final String VERSION_NAME = VERSION.toString();

Expand Down
30 changes: 30 additions & 0 deletions Logisim-Fork/com/cburch/logisim/file/XmlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import java.util.Map;

import javax.swing.JOptionPane;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -546,6 +547,35 @@ private void considerRepairs(Document doc, Element root) {
}
}
}
// compatibility message for gate inputs moved (only wide 4 inputs)
if (version.compareTo(LogisimVersion.get(2, 11, 1, 2)) < 0) {
for (Element circElt : XmlIterator.forChildElements(root, "circuit")) {
for (Element compElt : XmlIterator.forChildElements(circElt, "comp")) {
if (compElt.getAttribute("name").equals("AND Gate")
|| compElt.getAttribute("name").equals("NAND Gate")
|| compElt.getAttribute("name").equals("OR Gate")
|| compElt.getAttribute("name").equals("NOR Gate")
|| compElt.getAttribute("name").equals("XOR Gate")
|| compElt.getAttribute("name").equals("XNOR Gate")) {
boolean hasfourinputs = false;
boolean iswide = false;
// check if is wide and has 4 inputs
for (Element attrElt : XmlIterator.forChildElements(compElt, "a")) {
if (attrElt.getAttribute("name").equals("size") && attrElt.getAttribute("val").equals("70"))
hasfourinputs = true;
else if (attrElt.getAttribute("name").equals("inputs")
&& attrElt.getAttribute("val").equals("4"))
iswide = true;
}
if (hasfourinputs && iswide) {
JOptionPane.showMessageDialog(null,
"You could have to edit the position of all the gates that have 4 inputs and wide attribute\ndue to a bug in the input positions of the original Logisim",
"Compatibility problem", JOptionPane.WARNING_MESSAGE);
}
}
}
}
}
}

private Document loadXmlFrom(InputStream is) throws SAXException, IOException {
Expand Down
5 changes: 3 additions & 2 deletions Logisim-Fork/com/cburch/logisim/std/base/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class Text extends InstanceFactory {
public static Attribute<String> ATTR_TEXT = Attributes.forString("text", Strings.getter("textTextAttr"));
public static Attribute<Font> ATTR_FONT = Attributes.forFont("font", Strings.getter("textFontAttr"));
public static Attribute<Color> ATTR_COLOR = Attributes.forColor("color", Strings.getter("ioColorAttr"));
public static Attribute<AttributeOption> ATTR_HALIGN = Attributes.forOption("halign",
Strings.getter("textHorzAlignAttr"),
new AttributeOption[] {
Expand Down Expand Up @@ -120,7 +121,7 @@ public Bounds getOffsetBounds(AttributeSet attrsBase) {

@Override
protected void instanceAttributeChanged(Instance instance, Attribute<?> attr) {
if (attr == ATTR_HALIGN || attr == ATTR_VALIGN) {
if (attr == ATTR_HALIGN || attr == ATTR_VALIGN || attr == ATTR_COLOR) {
configureLabel(instance);
}
}
Expand All @@ -140,6 +141,7 @@ public void paintGhost(InstancePainter painter) {
Graphics g = painter.getGraphics();
Font old = g.getFont();
g.setFont(attrs.getFont());
g.setColor(painter.getAttributeValue(ATTR_COLOR));
GraphicsUtil.drawText(g, text, 0, 0, halign, valign);

String textTrim = text.endsWith(" ") ? text.substring(0, text.length() - 1) : text;
Expand All @@ -166,7 +168,6 @@ public void paintInstance(InstancePainter painter) {
int y = loc.getY();
Graphics g = painter.getGraphics();
g.translate(x, y);
g.setColor(Color.BLACK);
paintGhost(painter);
g.translate(-x, -y);
}
Expand Down
15 changes: 13 additions & 2 deletions Logisim-Fork/com/cburch/logisim/std/base/TextAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.cburch.logisim.std.base;

import java.awt.Color;
import java.awt.Font;
import java.util.Arrays;
import java.util.List;
Expand All @@ -14,18 +15,20 @@
import com.cburch.logisim.instance.StdAttr;

class TextAttributes extends AbstractAttributeSet {
private static final List<Attribute<?>> ATTRIBUTES = Arrays
.asList(new Attribute<?>[] { Text.ATTR_TEXT, Text.ATTR_FONT, Text.ATTR_HALIGN, Text.ATTR_VALIGN });
private static final List<Attribute<?>> ATTRIBUTES = Arrays.asList(
new Attribute<?>[] { Text.ATTR_TEXT, Text.ATTR_FONT, Text.ATTR_COLOR, Text.ATTR_HALIGN, Text.ATTR_VALIGN });

private String text;
private Font font;
private Color color;
private AttributeOption halign;
private AttributeOption valign;
private Bounds offsetBounds;

public TextAttributes() {
text = "";
font = StdAttr.DEFAULT_LABEL_FONT;
color = Color.BLACK;
halign = Text.ATTR_HALIGN.parse("center");
valign = Text.ATTR_VALIGN.parse("base");
offsetBounds = null;
Expand All @@ -49,6 +52,10 @@ int getHorizontalAlign() {
return ((Integer) halign.getValue()).intValue();
}

Color getLabelColor() {
return color;
}

Bounds getOffsetBounds() {
return offsetBounds;
}
Expand All @@ -63,6 +70,8 @@ public <V> V getValue(Attribute<V> attr) {
return (V) text;
if (attr == Text.ATTR_FONT)
return (V) font;
if (attr == Text.ATTR_COLOR)
return (V) color;
if (attr == Text.ATTR_HALIGN)
return (V) halign;
if (attr == Text.ATTR_VALIGN)
Expand All @@ -89,6 +98,8 @@ public <V> void setValue(Attribute<V> attr, V value) {
text = (String) value;
} else if (attr == Text.ATTR_FONT) {
font = (Font) value;
} else if (attr == Text.ATTR_COLOR) {
color = (Color) value;
} else if (attr == Text.ATTR_HALIGN) {
halign = (AttributeOption) value;
} else if (attr == Text.ATTR_VALIGN) {
Expand Down
2 changes: 2 additions & 0 deletions Logisim-Fork/com/cburch/logisim/std/io/Buzzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private static class Data implements InstanceData {
public volatile boolean sound_changed;
public volatile boolean still_alive;
public Thread thread;

public Data(boolean b) {
is_on = false;
freq = 100;
Expand All @@ -49,6 +50,7 @@ public Data(boolean b) {
is_on = b;
StartThread();
}

@Override
public Object clone() {
return new Data(is_on);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void paintInstance(InstancePainter painter) {
Graphics2D g = (Graphics2D) painter.getGraphics();
// draw border
painter.drawRoundBounds(painter.getAttributeValue(ATTR_COLOR));

// draw white space
g.setColor(new Color(250, 250, 250));
g.fillRoundRect(x + border, y + border, width - 2 * border, height - 2 * border, border / 2, border / 2);

Expand Down
5 changes: 3 additions & 2 deletions Logisim-Fork/com/cburch/logisim/std/io/Io.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Io extends Library {
static final Attribute<Color> ATTR_BACKGROUND = Attributes.forColor("bg", Strings.getter("ioBackgroundColor"));
static final Attribute<Object> ATTR_LABEL_LOC = Attributes.forOption("labelloc", Strings.getter("ioLabelLocAttr"),
new Object[] { LABEL_CENTER, Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST });
static final Attribute<Color> ATTR_LABEL_COLOR = Attributes.forColor("labelcolor",
public static final Attribute<Color> ATTR_LABEL_COLOR = Attributes.forColor("labelcolor",
Strings.getter("ioLabelColorAttr"));
static final Attribute<Boolean> ATTR_ACTIVE = Attributes.forBoolean("active", Strings.getter("ioActiveAttr"));
static final Attribute<Boolean> MULTI_BIT = Attributes.forBoolean("multibit", Strings.getter("ioMultiBit"));
Expand All @@ -36,7 +36,8 @@ public class Io extends Library {
new FactoryDescription("DipSwitch", Strings.getter("DipSwitchComponent"), "dipswitch.gif", "DipSwitch"),
new FactoryDescription("Joystick", Strings.getter("joystickComponent"), "joystick.gif", "Joystick"),
new FactoryDescription("Keyboard", Strings.getter("keyboardComponent"), "keyboard.gif", "Keyboard"),
//new FactoryDescription("Buzzer", Strings.getter("buzzerComponent"), "buzzer.gif", "Buzzer"),
// new FactoryDescription("Buzzer", Strings.getter("buzzerComponent"),
// "buzzer.gif", "Buzzer"),
new FactoryDescription("LED", Strings.getter("ledComponent"), "led.gif", "Led"),
new FactoryDescription("RGBLed", Strings.getter("rgbledComponent"), "rgbled.gif", "RGBLed"),
new FactoryDescription("Digital Oscilloscope", Strings.getter("DigitalOscilloscopeComponent"),
Expand Down
3 changes: 2 additions & 1 deletion Logisim-Fork/com/cburch/logisim/std/wiring/Wiring.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class Wiring extends Library {

private static Tool[] ADD_TOOLS = { new AddTool(SplitterFactory.instance), new AddTool(Pin.FACTORY),
new AddTool(Probe.FACTORY), new AddTool(Tunnel.FACTORY), new AddTool(PullResistor.FACTORY),
new AddTool(Clock.FACTORY), /*new AddTool(ProgrammableGenerator.FACTORY),*/ new AddTool(Constant.FACTORY), };
new AddTool(Clock.FACTORY),
/* new AddTool(ProgrammableGenerator.FACTORY), */ new AddTool(Constant.FACTORY), };

private static FactoryDescription[] DESCRIPTIONS = {
new FactoryDescription("Power", Strings.getter("powerComponent"), "power.gif", "Power"),
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ This is an italian fork based on the original Logisim version.<br>
* Programmable clock
* Suggest us everything at logisimit@gmail.com
## Retro-compatibility
I should have solved every problem with new changes, contact us if you have any kind of problem
Due to a bug in the original Logisim, wide gates with 4 inputs had a bad positioning of the ports.
I fixed this problem but if you open an old file containig gates with those attributes, its inputs will be disconnected and a warning message will appear
## EXE and JAR downloads + microprocessor project
All in our website [here](https://logisim.altervista.org)
## How to compile & use
Expand Down
7 changes: 4 additions & 3 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<!DOCTYPE xml>
<logisim>
<jar_file>https://github.com/LogisimIt/Logisim/raw/master/Compiled/Logisim-Fork.jar</jar_file>
<jar_version>2.11.2.1</jar_version>
<jar_version>2.11.2.5</jar_version>
<exe_file>https://github.com/LogisimIt/Logisim/raw/master/Compiled/Logisim-Fork.exe</exe_file>
<exe_version>2.11.2.1</exe_version>
<exe_version>2.11.2.5</exe_version>
<changelog>
* Led Matrix tooltips
* Label and Text Tool -> Added color attribute
* Added a warnin message if you open an old file with wide gates that have 4 inputs
</changelog>
</logisim>

0 comments on commit 339dfe7

Please sign in to comment.