-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ANSI/US symbol standard
- Loading branch information
Showing
15 changed files
with
244 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,6 @@ | |
*/ | ||
package lc.kra.jds.components.buildin.gate; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Point; | ||
import java.beans.PropertyVetoException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import lc.kra.jds.Utilities; | ||
import lc.kra.jds.components.Configurable; | ||
import lc.kra.jds.components.Configurable.Option.OptionType; | ||
|
@@ -32,6 +26,12 @@ | |
import lc.kra.jds.contacts.InputContact; | ||
import lc.kra.jds.contacts.OutputContact; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Point; | ||
import java.beans.PropertyVetoException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Abstract-Gate (build-in component) | ||
* @author Kristian Kraljic ([email protected]) | ||
|
@@ -50,13 +50,30 @@ public AbstractGate() { | |
contacts = ContactUtilities.concatenateContacts(output, inputs.toArray()); | ||
} | ||
|
||
@Override | ||
protected void changeSymbolStandard() { | ||
super.changeSymbolStandard(); | ||
if (inputs != null) | ||
inputs.setContactLocations(); | ||
if (output != null) | ||
output.setLocation(new Point(this.size.width, this.size.height / 2)); | ||
} | ||
|
||
@Override public void paint(Graphics graphics) { | ||
super.paint(graphics); | ||
Class<? extends AbstractGate> cls = this.getClass(); | ||
if(cls.equals(NandGate.class)||cls.equals(NorGate.class)||cls.equals(XnorGate.class)) | ||
ContactUtilities.paintSolderingJoint(graphics, 5, 3, output); | ||
ContactUtilities.paintSolderingJoint(graphics, 5, 3, output); | ||
else ContactUtilities.paintSolderingJoint(graphics, 5, 10, output); | ||
inputs.paintSolderingJoints(graphics, 5, 10); | ||
if (useAnsiSymbols) { | ||
if (cls.equals(OrGate.class)||cls.equals(NorGate.class)||cls.equals(XorGate.class)||cls.equals(XnorGate.class)) { | ||
inputs.paintSolderingJoints(graphics, 9, 10); | ||
} else { | ||
inputs.paintSolderingJoints(graphics, 5, 10); | ||
} | ||
} else { | ||
inputs.paintSolderingJoints(graphics, 5, 10); | ||
} | ||
} | ||
|
||
@Override public Contact[] getContacts() { return contacts; } | ||
|
@@ -75,4 +92,4 @@ public AbstractGate() { | |
configuration.put(getOptions()[0], inputs.getContactsCount()); | ||
return configuration; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,33 +17,47 @@ | |
*/ | ||
package lc.kra.jds.components.buildin.gate; | ||
|
||
import java.awt.Color; | ||
import java.awt.Dimension; | ||
import java.awt.Graphics; | ||
|
||
import lc.kra.jds.components.Component; | ||
import lc.kra.jds.components.Sociable; | ||
import lc.kra.jds.contacts.Contact; | ||
|
||
import java.awt.Color; | ||
import java.awt.Dimension; | ||
import java.awt.Graphics; | ||
|
||
/** | ||
* Gate (build-in component) | ||
* @author Kristian Kraljic ([email protected]) | ||
*/ | ||
public abstract class Gate extends Component implements Sociable { | ||
private static final long serialVersionUID = 2l; | ||
|
||
private static final Dimension ISO_SIZE = new Dimension(50, 48), ANSI_SIZE = new Dimension(55, 35); | ||
|
||
protected Dimension size; | ||
|
||
public Gate() { size = new Dimension(50, 48); } | ||
public Gate() { | ||
checkSymbolStandard(); | ||
} | ||
|
||
protected void changeSymbolStandard() { | ||
if (useAnsiSymbols) { | ||
size = ANSI_SIZE; | ||
} else { | ||
size = ISO_SIZE; | ||
} | ||
} | ||
|
||
@Override public void paint(Graphics graphics) { | ||
graphics.setColor(Color.BLACK); | ||
graphics.drawRect(5, 0, size.width-15, size.height); | ||
if (!useAnsiSymbols) { | ||
graphics.drawRect(5, 0, size.width-15, size.height); | ||
} | ||
} | ||
protected void paintLabel(Graphics graphics, String label) { graphics.drawString(label, 5+(size.width-15)/2-graphics.getFontMetrics().stringWidth(label)/2, 15); } | ||
protected void paintNot(Graphics graphics) { graphics.drawOval(size.width-10, size.height/2-3, 6, 6); } | ||
|
||
@Override public abstract Contact[] getContacts(); | ||
@Override public final Dimension getSize() { return size; } | ||
@Override public Dimension getSize() { return size; } | ||
@Override public abstract void calculate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,18 @@ | |
*/ | ||
package lc.kra.jds.components.buildin.gate; | ||
|
||
import static lc.kra.jds.Utilities.*; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Point; | ||
|
||
import lc.kra.jds.Utilities.TranslationType; | ||
import lc.kra.jds.contacts.Contact; | ||
import lc.kra.jds.contacts.ContactUtilities; | ||
import lc.kra.jds.contacts.InputContact; | ||
import lc.kra.jds.contacts.OutputContact; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Graphics; | ||
import java.awt.Point; | ||
|
||
import static lc.kra.jds.Utilities.getTranslation; | ||
|
||
/** | ||
* NOT-Gate (build-in component) | ||
* @author Kristian Kraljic ([email protected]) | ||
|
@@ -38,6 +39,7 @@ public class NotGate extends Gate { | |
private static final String KEY; | ||
static { KEY = "component.gate."+NotGate.class.getSimpleName().toLowerCase(); } | ||
public static final ComponentAttributes componentAttributes = new ComponentAttributes(KEY, getTranslation(KEY), "group.gate", getTranslation(KEY, TranslationType.DESCRIPTION), "Kristian Kraljic ([email protected])", 1); | ||
private static final Dimension ANSI_SIZE = new Dimension(45, 35); | ||
|
||
private InputContact input; | ||
private OutputContact output; | ||
|
@@ -50,15 +52,31 @@ public NotGate() { | |
contacts = new Contact[]{input, output}; | ||
} | ||
|
||
@Override | ||
protected void changeSymbolStandard() { | ||
super.changeSymbolStandard(); | ||
if (useAnsiSymbols) | ||
size = ANSI_SIZE; | ||
if (input != null) | ||
input.setLocation(new Point(0, this.size.height / 2)); | ||
if (output != null) | ||
output.setLocation(new Point(this.size.width, this.size.height / 2)); | ||
} | ||
|
||
@Override public void paint(Graphics graphics) { | ||
super.paint(graphics); | ||
ContactUtilities.paintSolderingJoints(graphics, contacts); | ||
paintLabel(graphics, "1"); | ||
if (useAnsiSymbols) { | ||
graphics.drawPolyline(new int[]{5, size.width - 11, 5, 5}, new int[]{0, size.height / 2, size.height, 0}, 4); | ||
} else { | ||
paintLabel(graphics, "1"); | ||
} | ||
paintNot(graphics); | ||
} | ||
|
||
@Override public Contact[] getContacts() { return contacts; } | ||
@Override public Dimension getSize() { return size; } | ||
@Override public void calculate() { | ||
output.setCharged(!input.isCharged()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.