This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign - Final release of v3.0 (#11)
* Fixed example 1 * Added verbose option to the CLI and fixed issue #9 * Fixed Example 2 * Make the runtime error pop up a window * Added the help button * Fixed issue #8 and improved Error reporting
- Loading branch information
Showing
6 changed files
with
246 additions
and
13 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
|
@@ -68,6 +68,7 @@ protected void move(String m) { | |
this.tape = newtape; | ||
|
||
this.head += 2; | ||
this.prevHead += 2; | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package app; | ||
|
||
import processing.core.PApplet; | ||
|
||
public class PButton { | ||
private static final float DEFAULT_MARGIN_X = 0.4f; | ||
private static final float DEFAULT_MARGIN_Y = 1f; | ||
|
||
private float x, y, width, height; | ||
private String text; | ||
private int bgColor, fgColor, hoverColor, hoverStrokeColor, strokeWidth, strokeColor, fontSize; | ||
private Action onPressed; | ||
|
||
public PButton(float x, float y, String text, PApplet app, Action act) { | ||
this.x = x; | ||
this.y = y; | ||
this.text = text; | ||
|
||
this.bgColor = 255; | ||
this.hoverColor = 200; | ||
this.hoverStrokeColor = 0; | ||
this.fgColor = 0; | ||
this.strokeWidth = 1; | ||
this.strokeColor = -1; | ||
|
||
this.fontSize = MainWindow.DEFAULT_FONT_SIZE; | ||
app.textSize(this.fontSize); | ||
|
||
this.width = app.textWidth(text) * (1 + DEFAULT_MARGIN_X); | ||
this.height = (app.textAscent() + app.textDescent()) * (1 + DEFAULT_MARGIN_Y); | ||
|
||
this.onPressed = act; | ||
} | ||
|
||
public void draw(PApplet app) { | ||
app.fill(bgColor); | ||
|
||
if(strokeColor != -1) { | ||
app.strokeWeight(strokeWidth); | ||
app.stroke(strokeColor); | ||
} | ||
|
||
app.rect(x, y, width, height); | ||
app.strokeWeight(1); | ||
|
||
app.textSize(fontSize); | ||
app.fill(fgColor); | ||
app.textAlign(PApplet.CENTER, PApplet.CENTER); | ||
app.text(text, x+width/2.0f, y+height/2.0f); | ||
|
||
} | ||
|
||
public void drawHovered(PApplet app) { | ||
app.fill(hoverColor); | ||
|
||
app.strokeWeight(strokeWidth); | ||
app.stroke(hoverStrokeColor); | ||
|
||
app.rect(x, y, width, height); | ||
app.strokeWeight(1); | ||
|
||
app.textSize(fontSize); | ||
app.fill(fgColor); | ||
app.textAlign(PApplet.CENTER, PApplet.CENTER); | ||
app.text(text, x+width/2.0f, y+height/2.0f); | ||
} | ||
|
||
public boolean hovered(float mX, float mY) { | ||
return mX > x && mX < x+width && | ||
mY > y && mY < y+height; | ||
} | ||
|
||
public void pressed(float mX, float mY, PApplet app) { | ||
this.onPressed.pressed(mX, mY, app); | ||
} | ||
|
||
public float getX() { | ||
return x; | ||
} | ||
|
||
public void setX(float x) { | ||
this.x = x; | ||
} | ||
|
||
public float getY() { | ||
return y; | ||
} | ||
|
||
public void setY(float y) { | ||
this.y = y; | ||
} | ||
|
||
public float getWidth() { | ||
return width; | ||
} | ||
|
||
public void setWidth(float width) { | ||
this.width = width; | ||
} | ||
|
||
public float getHeight() { | ||
return height; | ||
} | ||
|
||
public void setHeight(float height) { | ||
this.height = height; | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
public void setText(String text, PApplet app) { | ||
this.text = text; | ||
|
||
app.textSize(this.fontSize); | ||
|
||
this.width = app.textWidth(text) * (1 + DEFAULT_MARGIN_X); | ||
this.height = (app.textAscent() + app.textDescent()) * (1 + DEFAULT_MARGIN_Y); | ||
} | ||
|
||
public void setBgColor(int bgColor) { | ||
this.bgColor = bgColor; | ||
} | ||
|
||
public void setFgColor(int fgColor) { | ||
this.fgColor = fgColor; | ||
} | ||
|
||
public void setStrokeWidth(int strokeWidth) { | ||
this.strokeWidth = strokeWidth; | ||
} | ||
|
||
public void setStrokeColor(int strokeColor) { | ||
this.strokeColor = strokeColor; | ||
} | ||
|
||
public void setFontSize(int fontSize, PApplet app) { | ||
this.fontSize = fontSize; | ||
|
||
app.textSize(this.fontSize); | ||
|
||
this.width = app.textWidth(text) * (1 + DEFAULT_MARGIN_X); | ||
this.height = (app.textAscent() + app.textDescent()) * (1 + DEFAULT_MARGIN_Y); | ||
} | ||
|
||
public interface Action { | ||
void pressed(float mX, float mY, PApplet app); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package app; | ||
|
||
import javax.swing.JLabel; | ||
import java.awt.Graphics; | ||
import java.awt.Graphics2D; | ||
import java.awt.RenderingHints; | ||
|
||
class SmoothLabel extends JLabel { | ||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = -488310624992033567L; | ||
|
||
public SmoothLabel(String text) { | ||
super(text); | ||
} | ||
|
||
@Override | ||
protected void paintComponent(Graphics g) { | ||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
RenderingHints.VALUE_ANTIALIAS_ON); | ||
super.paintComponent(g); | ||
} | ||
} |