Skip to content

Commit 9a9f5cf

Browse files
committed
Change name of ImmediateDraw to InstantDraw
(cherry picked from commit 62ab5e9)
1 parent 8091172 commit 9a9f5cf

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

INTRODUCTION.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ or as [JavaDoc](https://krassnig.github.io/CodeDrawJavaDoc/).
2020
* [Modifying the way things are drawn](#modifying-the-way-things-are-drawn)
2121
* [Drawing text](#drawing-text)
2222
* [Canvas and window](#canvas-and-window)
23-
* [Debugging CodeDraw and ImmediateDraw](#debugging-codedraw-and-immediatedraw)
23+
* [Debugging CodeDraw and drawing instantly](#debugging-codedraw-and-drawing-instantly)
2424
* [Points, lines and curves](#points-lines-and-curves)
2525
* [Outline and filled shapes](#outline-and-filled-shapes)
2626
* [Images in CodeDraw](#images-in-codedraw)
@@ -226,7 +226,7 @@ Methods about the CodeDraw window:
226226
- getCanvasPositionX/setCanvasPositionX
227227
- getCanvasPositionY/getCanvasPositionY
228228

229-
## Debugging CodeDraw and ImmediateDraw
229+
## Debugging CodeDraw and drawing instantly
230230

231231
When debugging CodeDraw in Intellij, Intellij stops the entire Program including the CodeDraw window and your Code.
232232
To make Intellij only stop your Code and not make the CodeDraw window freeze when debugging follow these 4 steps:
@@ -238,7 +238,7 @@ To make Intellij only stop your Code and not make the CodeDraw window freeze whe
238238

239239
![06 Debugging CodeDraw and ImmediateDraw](https://user-images.githubusercontent.com/24553082/156898569-6dbc7bb0-b5f2-43d7-a423-078d82d37767.png)
240240

241-
When ImmediateDraw is enabled CodeDraw will immediately draw all shapes to the canvas.
241+
When InstantDraw is enabled CodeDraw will instantly draw all shapes to the canvas.
242242
This can be used to better understand what is happening in your application
243243
but also slows down drawing object because CodeDraw has to render each time.
244244

@@ -248,16 +248,16 @@ Additionally, you can setAlwaysOnTop to true that CodeDraw doesn't disappear beh
248248
import codedraw.*;
249249

250250
public class Main {
251-
public static void main(String[] args) {
252-
CodeDraw cd = new CodeDraw();
253-
cd.enableImmediateDraw();
254-
cd.setAlwaysOnTop(true);
255-
256-
cd.drawCircle(300, 300, 100);
257-
258-
// The circle is displayed without calling
259-
// cd.show();
260-
}
251+
public static void main(String[] args) {
252+
CodeDraw cd = new CodeDraw();
253+
cd.setInstantDraw(true);
254+
cd.setAlwaysOnTop(true);
255+
256+
cd.drawCircle(300, 300, 100);
257+
258+
// The circle is displayed without calling
259+
// cd.show();
260+
}
261261
}
262262
```
263263

src/main/java/codedraw/CodeDraw.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,26 @@ public CodeDraw(int canvasWidth, int canvasHeight) {
8686
private CodeDrawImage g;
8787
private EventCollection events;
8888
private Subscription ctrlCSubscription;
89-
private boolean drawImmediately = false;
89+
private boolean isInstantDraw = false;
9090

9191
/**
92-
* When ImmediateDraw is enabled CodeDraw will immediately draw all shapes to the canvas.
93-
* Enabling ImmediateDraw makes CodeDraw slow.
92+
* When InstantDraw is disabled CodeDraw will only draw shapes to the window once show is called.
93+
* When InstantDraw is enabled CodeDraw will immediately draw all shapes to the canvas.
9494
* ImmediateDraw is disabled per default.
95+
* @return whether InstantDraw is enabled.
9596
*/
96-
public void enableImmediateDraw() {
97-
drawImmediately = true;
97+
public boolean isInstantDraw() {
98+
return isInstantDraw;
9899
}
99100

100101
/**
101-
* When ImmediateDraw is disabled CodeDraw will only draw shapes to the window once show is called.
102-
* ImmediateDraw is disabled per default.
102+
* When InstantDraw is disabled CodeDraw will only draw shapes to the window once show is called.
103+
* When InstantDraw is enabled CodeDraw will immediately draw all shapes to the canvas.
104+
* InstantDraw is disabled per default.
105+
* @param isInstantDraw defines whether InstantDraw is enabled.
103106
*/
104-
public void disableImmediateDraw() {
105-
drawImmediately = false;
107+
public void setInstantDraw(boolean isInstantDraw) {
108+
this.isInstantDraw = isInstantDraw;
106109
}
107110

108111
/**
@@ -1052,7 +1055,7 @@ public void clear(Color color) {
10521055
*/
10531056
public void show() {
10541057
checkEventInvocation();
1055-
window.render(g, drawImmediately);
1058+
window.render(g, isInstantDraw);
10561059
}
10571060

10581061
/**
@@ -1098,7 +1101,7 @@ public void close(boolean terminateProcess) {
10981101
}
10991102

11001103
private void afterDrawing() {
1101-
if (drawImmediately) show();
1104+
if (isInstantDraw) show();
11021105
}
11031106

11041107
@Override

0 commit comments

Comments
 (0)