Skip to content

Commit f97217a

Browse files
committed
Merge branch 'develop' of https://github.com/UCSDOalads/JavaSketchPad into addGlobalFileActions
2 parents 505439d + 9ded3ef commit f97217a

7 files changed

Lines changed: 34 additions & 12 deletions

File tree

src/actions/AddDataDisplayBoxAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public AddDataDisplayBoxAction(PaintPanel panel) {
2020

2121
@Override
2222
public boolean canPerformAction() {
23+
2324
return true;
2425
}
2526

src/actions/AddDataInputBoxAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void performAction() {
2828
}
2929
panel.addPaintComponent(comp);
3030

31+
3132

3233
//push action to the manager
3334
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {

src/actions/UpdateDataDisplayBoxAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public UpdateDataDisplayBoxAction(PaintPanel panel) {
2222

2323
@Override
2424
public boolean canPerformAction() {
25+
2526
if(panel.getSelectTool().getSelectedComponents().size() == 1){
2627
if(panel.getSelectTool().getSelectedComponents().get(0) instanceof DataDisplayPaintComponent){
27-
return true;
28+
return ((DataDisplayPaintComponent) panel.getSelectTool().getSelectedComponents().get(0)).canUpdate();
2829
}
2930
}
3031
return false;

src/actions/global/globalactions/AddDataDisplayBoxGlobalAction.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class AddDataDisplayBoxGlobalAction extends GlobalPaintAction {
1515
private String dataDisplay;
1616
private int x;
1717
private int y;
18+
private DataDisplayPaintComponent comp;
1819

1920
public void setDisplayString(String dataDisplay) {
2021
this.dataDisplay = dataDisplay;
@@ -38,8 +39,12 @@ public void setY(int y) {
3839

3940
@Override
4041
protected void execute(PaintPanel panel) {
41-
DataDisplayPaintComponent comp = new DataDisplayPaintComponent(
42+
comp = new DataDisplayPaintComponent(
4243
dataDisplay, x, y);
44+
if (panel.getSelectTool() != null) {
45+
panel.getSelectTool().clearSelection();
46+
panel.getSelectTool().selectComponent(comp);
47+
}
4348
panel.addPaintComponent(comp);
4449

4550
// push action to manager
@@ -71,5 +76,9 @@ protected String commandDescription() {
7176
});
7277
panel.repaint();
7378
}
79+
80+
public DataDisplayPaintComponent getComponent() {
81+
return comp;
82+
}
7483

7584
}

src/icons/LeftArrow.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ public static Polygon getPolygon(){
9494

9595
Polygon p = new Polygon();
9696

97-
p.addPoint(8, 0);
98-
p.addPoint(0, 9);
99-
p.addPoint(8, 20);
100-
p.addPoint(8, 17);
101-
p.addPoint(8, 14);
102-
p.addPoint(40, 15);
103-
p.addPoint(40, 8);
104-
p.addPoint(8, 7);
105-
p.addPoint(8, 1);
97+
p.addPoint(8, 5);
98+
p.addPoint(0, 14);
99+
p.addPoint(8, 25);
100+
p.addPoint(8, 22);
101+
p.addPoint(8, 19);
102+
p.addPoint(40, 20);
103+
p.addPoint(40, 13);
104+
p.addPoint(8, 12);
105+
p.addPoint(8, 6);
106106

107107

108108
return p;

src/paintcomponents/data/DataDisplayPaintComponent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ public void updateDisplayText() throws NoSuchElementException, NoConnectingLineS
4242
}
4343
}
4444

45+
public boolean canUpdate(){
46+
try {
47+
Object data = getToPoints().get(0).fetchData();
48+
if(data instanceof String){
49+
return true;
50+
}
51+
} catch (Exception e) {
52+
return false;
53+
}
54+
return false;
55+
}
4556
@Override
4657
public void saveToElement(Element rootElement, Document doc) {
4758
super.saveToElement(rootElement, doc);

src/painttools/tools/SelectTool.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ public void mouseMoved(MouseEvent e) {
246246
@Override
247247
public void start(PaintPanel panel) {
248248
this.panel = panel;
249-
250249
}
251250

252251
@Override

0 commit comments

Comments
 (0)