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

Added. #2

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
090cf8d
First commit
invalid-email-address Jan 27, 2011
9bb69df
Updated the name and readme
invalid-email-address Feb 24, 2011
7b08a45
+ Heh.
invalid-email-address Feb 25, 2011
ed12290
Fix invalid HTML
dave1010 Mar 2, 2011
f756e52
doctype html
invalid-email-address Mar 2, 2011
fd0a1b2
lowercase doctype html, uppercase untitled, no width/height on img, s…
invalid-email-address Mar 27, 2011
79a1dc0
Added hidden double rainbow reference; added title
zhuowei Apr 2, 2011
bdd3996
Merged pull request #9.
Apr 21, 2011
1c27c20
Created a class that stores the constants used further.
Oct 17, 2013
c5ed234
This creates the GUI for the proyect. Used Google Window Builder.
Oct 17, 2013
a88e110
Removed one file.
Oct 17, 2013
0c5ee84
Added a panel instead of the canvas, since canvas couldnt draw.
Oct 17, 2013
c3a303d
Added images for every logic gate. Class that storages constants. GUI…
Oct 21, 2013
da3697e
Merge remote-tracking branch 'upstream/master'
Oct 21, 2013
4b37053
Delete README
Oct 22, 2013
1658780
More changes
Oct 22, 2013
c08aa01
Merge pull request #1 from jeukel/master
Oct 22, 2013
e21f882
Lastest Stuff
Oct 30, 2013
bcfa6f1
removed "DibujarLineas" , removed " MouseLocation". they were never u…
Nov 2, 2013
7831dd3
removed "MyPanel". we were not using it.
Nov 2, 2013
225153b
Removed the code inside the toggleButton "ConnectTo"
Nov 2, 2013
00bbd4d
Removed manager, GUI is the real manager. LUI now implements redo , u…
Nov 3, 2013
327ab01
It draw lines now !!
Nov 3, 2013
411460a
Changed the way the logic gate was setting its root. It was crashing …
Nov 4, 2013
4c205f6
Joining Logic with Graphics through a GUI class.
Nov 4, 2013
d4aae1d
Created methods for certain stuff. Having the issue that when we crea…
Nov 4, 2013
b226cda
Made some changes. Now it saves into a XML. Changed the way gates wer…
Zyoruk Nov 5, 2013
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
8 changes: 8 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="forms-1.3.0.jar" sourcepath="forms-1.3.0-src.zip"/>
<classpathentry kind="lib" path="miglayout15-swing.jar" sourcepath="miglayout-src.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LogiCTec</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
1 change: 1 addition & 0 deletions NewComponent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><Component><ExitTree exit="3"><node>1</node><node>0</node><node>0</node></ExitTree></Component>
Binary file added forkit.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forms-1.3.0-src.zip
Binary file not shown.
Binary file added imagenescompuertas/and.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagenescompuertas/nand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagenescompuertas/nor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagenescompuertas/not.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagenescompuertas/or.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagenescompuertas/xnor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagenescompuertas/xor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>Spoon-Knife</title>
<style type="text/css">
* {
margin:0px;
padding:0px;
}

#octocat {
display: block;
width:384px;
margin: 50px auto;
}

p {
display: block;
width: 400px;
margin: 50px auto;
font: 30px Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
}
#rainbow-message {
position: absolute;
right: 10px;
top: 10px;
box-shadow: -5px 10px 15px gray;
-moz-box-shadow: -5px 10px 15px gray;
font-family: sans-serif;
}

</style>
<script type="text/javascript">
var keyCodes=new Array(10);
var pattern=[38,38,40,40,37,39,37,39,66,65];
function keydownHandler(e){
keyCodes.shift();
keyCodes.push(e.keyCode);
if(keyCodes.every(function(element, index, array){return element===pattern[index];})){
document.getElementById("rainbow-message").style.display="";
}
}
window.onkeydown=keydownHandler;
</script>

</head>

<body>

<img src="forkit.gif" id="octocat" alt="" />

<p>
Fork me? No, fork you!
</p>
<div id="rainbow-message" style="display:none">
Double repositories all the way across the sky!<br/>
<a href="http://help.github.com/fork-a-repo/">What does it mean?</a>
</div>
</body>
</html>
Binary file added miglayout-src.zip
Binary file not shown.
40 changes: 40 additions & 0 deletions src/edu/itcr/logictec/constants/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package edu.itcr.logictec.constants;


/**
* Clase que nos sirve para guardar constantes, de esta manera nos ahorramos
* estar escribiendo literales dentro del codigo. De esta manera, el codigo se
* mejor y será más fácil simplemente llamar las distintas constantes.
* @author zyoruk
*
*/
public class Constants {
public static final String menuGIF = "/javax/swing/plaf/metal/icons" +
"/ocean/menu.gif";

public static final String directoryGIF = "/javax/swing/plaf/metal/icons" +
"/ocean/directory.gif";

public static final String floppyGIF = "/javax/swing/plaf/metal/icons/" +
"ocean/floppy.gif";

public static final String infoGIF = "/javax/swing/plaf/metal/icons/" +
"ocean/info.png";

public static final String andImage = "imagenescompuertas/and.png";

public static final String nandImage = "imagenescompuertas/nand.png";

public static final String norImage = "imagenescompuertas/nor.png";

public static final String notImage ="imagenescompuertas/not.png";

public static final String orImage = "imagenescompuertas/or.png";

public static final String xnorImage = "imagenescompuertas/xnor.png";

public static final String xorImage = "imagenescompuertas/xor.png";

public static final String fileXML = "NewComponent.xml";

}
198 changes: 198 additions & 0 deletions src/edu/itcr/logictec/graphicaluserinterface/DrawGate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
package edu.itcr.logictec.graphicaluserinterface;

/**
* Class on charge of drawing the respective gate with its image.
* It creates a MyLabel.
*/

import java.awt.Component;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JTextField;
import edu.itcr.logictec.constants.Constants;

public class DrawGate{
private int _x;
private int _y;
private int _height;
private String _gateKind;
private MyPanel panel_1;
private int i = 0;
private Component[] components ;
private MyLabel[] labelList;
private JTextField input1;
private JTextField input2;
private JTextField output;
private GUI theGUI;

public DrawGate(){
components = new Component[10];
}

public DrawGate(int px,int py,int ph,String ptc,MyPanel pPanel_1, MyLabel[] pLabelList, GUI pGUI){
_x = px;
_y = py;
_height = ph;
_gateKind = ptc;
panel_1 = pPanel_1;
components = new Component[10];
labelList = pLabelList;
input1 = new JTextField();
input2 = new JTextField();
output = new JTextField();
theGUI = pGUI;
}

/**
* Paint the logic gate with its inputs and outputs.
* @throws IOException
* @author Zyoruk
*/
public MyLabel paint() throws IOException{
BufferedImage image;

if (_gateKind == "AND"){
image = ImageIO.read(new File(Constants.andImage));

}else if (_gateKind == "NAND"){
image = ImageIO.read(new File(Constants.nandImage));

}else if (_gateKind == "XOR"){
image = ImageIO.read(new File(Constants.xorImage));

}else if (_gateKind == "XNOR"){
image = ImageIO.read(new File(Constants.xnorImage));

}else if (_gateKind == "OR"){
image = ImageIO.read(new File(Constants.orImage));

}else if (_gateKind == "NOR"){
image = ImageIO.read(new File(Constants.norImage));

}else{
image = ImageIO.read(new File(Constants.notImage));
}

MyLabel picLabel = new MyLabel(new ImageIcon(image), panel_1, _gateKind, theGUI);

/*
* We create 3 textfields for every new gate.
* The "Not" gate has only one input, then we dont add to it a textfield
*/
if(_gateKind != "NOT"){
picLabel.add(input1);
input1.setBounds(0, 0, 20, 20);
input1.setText("0");
}

picLabel.add(input2);
input2.setBounds(0,50, 20, 20);
input2.setText("0");

picLabel.add(output);
output.setBounds(80,50, 20, 20);

panel_1.add(picLabel);
picLabel.setBounds(_x,_y,_height,_height);

//Creates a temporal list of components
for(int i = 0 ; i < panel_1.getComponentCount();i++){
if(i != 9){
components[i] = panel_1.getComponent(i);
}else{
break;
}
}

return picLabel;
}

/**
* Undo the last change made.
* @author Zyoruk
*/
public void unDo(){
if (panel_1.getComponentCount()!=0){
panel_1.remove(panel_1.getComponentCount() - 1);
panel_1.repaint();
if(i != 0){
i--;
}
}
}

/**
* Redo the last change.
* @author Zyoruk
*/
public void reDo(){
if (i < components.length){
if (components[i] !=null){
panel_1.add(components[i]);
panel_1.repaint();
i++;
}
}
}

/**
* return the kind of gate that has been created
* @return _gateKind which is a String.
*/
public String getGateKind(){
return this._gateKind;
}

/**
* Gets the list of MyLabels created
* @return lalbelList
*/
public MyLabel[] getListOfLabels(){
return this.labelList;
}

/**
* Gets the value of the input 1 as an Integer.
* @return temp
*/
public int getInA(){
int temp = Integer.parseInt(this.input1.getText());
return temp;
}

/**
* Gets the value of the input 2 as an Integer.
* @return temp
*/
public int getInB(){
int temp = Integer.parseInt(this.input2.getText());
return temp;
}

/**
* Sets the value of the Input1
* @param pInput1
*/
public void setInA(String pInput1){
this.input1.setText(pInput1);
}

/**
* Sets the value of the Input2
* @param pInput2
*/
public void setInB(String pInput2){
this.input2.setText(pInput2);
}

/**
* sets the value for the output of the gate
* @param pOut
*/
public void setOut(String pOut){
this.output.setText(pOut);
}
}
Loading