Skip to content

Commit 57afcb8

Browse files
authored
Merge branch 'develop' into addCompilerByXiaoquan
2 parents 631972c + 6ad0daf commit 57afcb8

51 files changed

Lines changed: 1835 additions & 99 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8
4+
5+
before_script:
6+
- "export DISPLAY=:99.0"
7+
- "sh -e /etc/init.d/xvfb start"
8+
- sleep 3 # give xvfb some time to start
9+
10+
notifications:
11+
email: false

TODOList.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
1. File Save/Close Operations
22
2. Edit Undo/Redo Operations
3-
3. More usable SelectTools
4-
4. Remove Functinoality
5-
5. Zooming and Scrolling and Moving Function
3+
//3. More usable SelectTools
4+
//4. Remove Functinoality
5+
//5. Zooming and Scrolling and Moving Function
66
6. Data Point Connection Types
77
7. Available Class Search
88
8. Auto-Update Display Box Affected by Recent Changes
99
9. Debug Undo Function
1010
10. Type Cast try (String) catch
11+
12+
13+
14+
1. File Save
15+
2. ClassSearch
16+
11. Display history
17+
12.
18+
13.

build.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<project name="JavaSketchPad" default="run" basedir=".">
2+
<property name="build.dir" location="ant_build" />
3+
<property name="src.dir" location="src" />
4+
5+
<target name="init" description="Creating directory">
6+
<mkdir dir="${build.dir}" />
7+
</target>
8+
9+
<target name="compile" depends="init" description="Compiling Sources">
10+
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false">
11+
<classpath refid="classpath.test" />
12+
</javac>
13+
</target>
14+
15+
<target name="run" depends="compile" description="Running the program">
16+
</target>
17+
18+
<target name="clean">
19+
<delete dir="${build.dir}" />
20+
</target>
21+
22+
23+
<path id="classpath.test">
24+
<pathelement location="lib/junit-4.12.jar" />
25+
<pathelement location="lib/hamcrest-core-1.3.jar" />
26+
<pathelement location="${build.dir}" />
27+
</path>
28+
29+
30+
<target name="test" depends="compile">
31+
<junit printsummary="on" haltonfailure="yes" fork="true">
32+
<classpath>
33+
<path refid="classpath.test" />
34+
<pathelement location="${test.build.dir}" />
35+
</classpath>
36+
<formatter type="brief" usefile="false" />
37+
<batchtest>
38+
<fileset dir="${src.dir}" includes="**/*Test.java" />
39+
</batchtest>
40+
</junit>
41+
</target>
42+
</project>

lib/hamcrest-core-1.3.jar

44 KB
Binary file not shown.

lib/junit-4.12.jar

308 KB
Binary file not shown.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package actions;
2+
3+
import java.util.ArrayList;
4+
5+
import javax.swing.JOptionPane;
6+
7+
import actions.menu.ActionsMenuBarTitles;
8+
import actions.singleinstanceoperations.SingleInstanceOperation;
9+
import paintcomponents.PaintComponent;
10+
import paintcomponents.annotations.TextAnnotation;
11+
import paintcomponents.data.DataTextPaintComponent;
12+
import ui.PaintPanel;
13+
14+
/**
15+
* add the annotation to a component
16+
*
17+
* @author muchi
18+
*
19+
*/
20+
public class AddAnnotationAction extends SingleInstanceOperation<PaintComponent>{
21+
22+
/**
23+
* ctor
24+
* @param panel the panel
25+
*/
26+
public AddAnnotationAction(PaintPanel panel) {
27+
super(panel);
28+
}
29+
30+
/**
31+
* @return the location of the button
32+
*/
33+
@Override
34+
public String locationString() {
35+
return ActionsMenuBarTitles.Data().Annotations().Add().toString();
36+
}
37+
38+
@Override
39+
protected void performActionOnInstance(PaintComponent instance) {
40+
// TODO Auto-generated method stub
41+
String annotations = JOptionPane
42+
.showInputDialog("Please specify the annotation of the component");
43+
new TextAnnotation(instance, annotations);
44+
45+
}
46+
47+
@Override
48+
protected Class<PaintComponent> getGenericClassType() {
49+
return PaintComponent.class;
50+
}
51+
52+
53+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package actions;
2+
3+
import ui.PaintPanel;
4+
5+
import java.lang.reflect.Method;
6+
7+
import javax.swing.JOptionPane;
8+
9+
import actions.menu.ActionsMenuBarTitles;
10+
import paintcomponents.java.lazy.ClassPaintComponent;
11+
import paintcomponents.java.lazy.InstanceOperationComponent;
12+
import paintcomponents.java.lazy.MethodPaintComponent;
13+
14+
public class AddInstanceMethodAction extends PaintAction {
15+
16+
public AddInstanceMethodAction(PaintPanel panel) {
17+
super(panel);
18+
}
19+
20+
@Override
21+
public boolean canPerformAction() {
22+
if (panel.getSelectTool().getSelectedComponents().size() != 1) {
23+
return false;
24+
}
25+
if (panel.getSelectTool().getSelectedComponents()
26+
.get(0) instanceof InstanceOperationComponent) {
27+
return true;
28+
}
29+
return false;
30+
}
31+
32+
@Override
33+
public void performAction() {
34+
InstanceOperationComponent insComp =
35+
(InstanceOperationComponent)panel.getSelectTool().
36+
getSelectedComponents().get(0);
37+
Method[] methods = insComp.getDisplayingClass().getMethods();
38+
39+
int desiaredConstructorIndex = Integer
40+
.parseInt(JOptionPane.showInputDialog(
41+
"Please enter the index of the constructor you would like to use: \n\n\n"
42+
+ getMethodsSelectionUI(methods)));
43+
insComp.addMethodPaintComponent(methods[desiaredConstructorIndex], panel);
44+
panel.repaint();
45+
}
46+
47+
@Override
48+
public String locationString() {
49+
// TODO Auto-generated method stub
50+
return ActionsMenuBarTitles.Lazy().Add().Add_Instance_Method().toString();
51+
}
52+
53+
public String getMethodsSelectionUI(Method[] methods) {
54+
StringBuilder builder = new StringBuilder();
55+
for (int i = 0; i < methods.length; i++) {
56+
Method constructor = methods[i];
57+
builder.append(i + " : " + constructor.toString() + "\n");
58+
}
59+
return builder.toString();
60+
61+
}
62+
63+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package actions;
2+
3+
import java.lang.reflect.Constructor;
4+
import java.lang.reflect.Method;
5+
6+
import actions.edit.undoredo.SharedUndoRedoActionManager;
7+
import actions.edit.undoredo.UndoRedoableInterface;
8+
import actions.menu.ActionsMenuBarTitles;
9+
import paintcomponents.java.lazy.InstanceOperationComponent;
10+
import paintcomponents.java.lazy.ClassPaintComponent;
11+
import ui.PaintPanel;
12+
13+
import javax.swing.JOptionPane;
14+
15+
16+
public class AddInstanceOperationAction extends PaintAction {
17+
18+
19+
public AddInstanceOperationAction(PaintPanel panel) {
20+
super(panel);
21+
}
22+
23+
@Override
24+
public boolean canPerformAction() {
25+
if (panel.getSelectTool().getSelectedComponents().size() != 1) {
26+
return false;
27+
}
28+
if (panel.getSelectTool().getSelectedComponents()
29+
.get(0) instanceof ClassPaintComponent) {
30+
return true;
31+
}
32+
return false;
33+
}
34+
35+
@Override
36+
public void performAction() {
37+
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool()
38+
.getSelectedComponents().get(0);
39+
Constructor[] cons = comp.getDisplayingClass().getConstructors();
40+
41+
int desiaredConstructorIndex = Integer
42+
.parseInt(JOptionPane.showInputDialog(
43+
"Please enter the index of the constructor you would like to use: \n\n\n"
44+
+ getConstructorsSelectionUI(cons)));
45+
InstanceOperationComponent consComp = new InstanceOperationComponent(
46+
cons[desiaredConstructorIndex], panel.getWidth() / 2,
47+
panel.getHeight() / 2);
48+
panel.addPaintComponent(consComp);
49+
// add action to undo redo manager
50+
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
51+
52+
@Override
53+
public void undoAction() {
54+
consComp.remove(panel);
55+
panel.repaint();
56+
}
57+
58+
@Override
59+
public void redoAction() {
60+
panel.addPaintComponent(consComp);
61+
panel.repaint();
62+
}
63+
});
64+
panel.repaint();
65+
}
66+
67+
public String getConstructorsSelectionUI(Constructor[] cons) {
68+
StringBuilder builder = new StringBuilder();
69+
for (int i = 0; i < cons.length; i++) {
70+
Constructor constructor = cons[i];
71+
builder.append(i + " : " + constructor.toString() + "\n");
72+
}
73+
return builder.toString();
74+
75+
}
76+
77+
@Override
78+
public String locationString() {
79+
return ActionsMenuBarTitles.Lazy().Add().Instance_Operation().toString();
80+
}
81+
82+
83+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package actions;
2+
3+
import java.lang.reflect.Constructor;
4+
5+
import javax.swing.JOptionPane;
6+
7+
import actions.edit.undoredo.SharedUndoRedoActionManager;
8+
import actions.edit.undoredo.UndoRedoableInterface;
9+
import actions.menu.ActionsMenuBarTitles;
10+
import paintcomponents.java.interactive.ClassConstructorPaintComponent;
11+
import paintcomponents.java.lazy.ClassPaintComponent;
12+
import ui.PaintPanel;
13+
14+
public class AddInteractiveConstructorAction extends PaintAction {
15+
16+
public AddInteractiveConstructorAction(PaintPanel panel) {
17+
super(panel);
18+
}
19+
20+
@Override
21+
public boolean canPerformAction() {
22+
if (panel.getSelectTool().getSelectedComponents().size() != 1) {
23+
return false;
24+
}
25+
if (panel.getSelectTool().getSelectedComponents()
26+
.get(0) instanceof ClassPaintComponent) {
27+
return true;
28+
}
29+
return false;
30+
}
31+
32+
@Override
33+
public void performAction() {
34+
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool()
35+
.getSelectedComponents().get(0);
36+
Constructor[] cons = comp.getDisplayingClass().getConstructors();
37+
38+
int desiaredConstructorIndex = Integer
39+
.parseInt(JOptionPane.showInputDialog(
40+
"Please enter the index of the constructor you would like to use: \n\n\n"
41+
+ getConstructorsSelectionUI(cons)));
42+
ClassConstructorPaintComponent consComp = new ClassConstructorPaintComponent(
43+
cons[desiaredConstructorIndex], panel.getWidth() / 2,
44+
panel.getHeight() / 2);
45+
panel.addPaintComponent(consComp);
46+
// add action to undo redo manager
47+
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
48+
49+
@Override
50+
public void undoAction() {
51+
consComp.remove(panel);
52+
panel.repaint();
53+
}
54+
55+
@Override
56+
public void redoAction() {
57+
panel.addPaintComponent(consComp);
58+
panel.repaint();
59+
}
60+
});
61+
panel.repaint();
62+
}
63+
64+
public String getConstructorsSelectionUI(Constructor[] cons) {
65+
StringBuilder builder = new StringBuilder();
66+
for (int i = 0; i < cons.length; i++) {
67+
Constructor constructor = cons[i];
68+
builder.append(i + " : " + constructor.toString() + "\n");
69+
}
70+
return builder.toString();
71+
72+
}
73+
74+
@Override
75+
public String locationString() {
76+
return ActionsMenuBarTitles.Developer("Interactive/Constructor").toString();
77+
}
78+
79+
}

0 commit comments

Comments
 (0)