Skip to content

Commit c07f452

Browse files
committed
Remove deprecated methods
1 parent 45b87f0 commit c07f452

File tree

2 files changed

+39
-52
lines changed

2 files changed

+39
-52
lines changed

core/src/processing/core/PApplet.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,8 +2596,6 @@ public void focusLost() { }
25962596
// getting the time
25972597

25982598

2599-
static protected Time time = new Time();
2600-
26012599
/**
26022600
* Get the number of milliseconds since the applet started.
26032601
* <P>
@@ -2610,16 +2608,12 @@ public int millis() {
26102608

26112609
/** Seconds position of the current time. */
26122610
static public int second() {
2613-
//return Calendar.getInstance().get(Calendar.SECOND);
2614-
time.setToNow();
2615-
return time.second;
2611+
return Calendar.getInstance().get(Calendar.SECOND);
26162612
}
26172613

26182614
/** Minutes position of the current time. */
26192615
static public int minute() {
2620-
//return Calendar.getInstance().get(Calendar.MINUTE);
2621-
time.setToNow();
2622-
return time.minute;
2616+
return Calendar.getInstance().get(Calendar.MINUTE);
26232617
}
26242618

26252619
/**
@@ -2630,9 +2624,7 @@ static public int minute() {
26302624
* if (yankeeHour == 0) yankeeHour = 12;</PRE>
26312625
*/
26322626
static public int hour() {
2633-
//return Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
2634-
time.setToNow();
2635-
return time.hour;
2627+
return Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
26362628
}
26372629

26382630
/**
@@ -2642,28 +2634,22 @@ static public int hour() {
26422634
* or day of the year (1..365) then use java's Calendar.get()
26432635
*/
26442636
static public int day() {
2645-
//return Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
2646-
time.setToNow();
2647-
return time.monthDay;
2637+
return Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
26482638
}
26492639

26502640
/**
26512641
* Get the current month in range 1 through 12.
26522642
*/
26532643
static public int month() {
26542644
// months are number 0..11 so change to colloquial 1..12
2655-
//return Calendar.getInstance().get(Calendar.MONTH) + 1;
2656-
time.setToNow();
2657-
return time.month + 1;
2645+
return Calendar.getInstance().get(Calendar.MONTH) + 1;
26582646
}
26592647

26602648
/**
26612649
* Get the current year.
26622650
*/
26632651
static public int year() {
2664-
//return Calendar.getInstance().get(Calendar.YEAR);
2665-
time.setToNow();
2666-
return time.year;
2652+
return Calendar.getInstance().get(Calendar.YEAR);
26672653
}
26682654

26692655

core/src/processing/core/PGraphicsAndroid2D.java

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ protected void allocate() {
147147
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
148148
canvas = new Canvas(bitmap);
149149
}
150-
// image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
151-
// canvas = (Graphics2D) image.getGraphics();
152150
}
153151

154152

@@ -458,7 +456,8 @@ public void breakShape() {
458456
@Override
459457
public void endShape(int mode) {
460458
if (shape == POINTS && stroke && vertexCount > 0) {
461-
Matrix m = canvas.getMatrix();
459+
// Matrix m = canvas.getMatrix();
460+
Matrix m = getMatrixImp();
462461
if (strokeWeight == 1 && m.isIdentity()) {
463462
if (screenPoint == null) {
464463
screenPoint = new float[2];
@@ -1527,8 +1526,9 @@ public PMatrix2D getMatrix(PMatrix2D target) {
15271526
target = new PMatrix2D();
15281527
}
15291528
// canvas.getTransform().getMatrix(transform);
1530-
Matrix m = new Matrix();
1531-
canvas.getMatrix(m);
1529+
// Matrix m = new Matrix();
1530+
// canvas.getMatrix(m);
1531+
Matrix m = getMatrixImp();
15321532
m.getValues(transform);
15331533
// target.set((float) transform[0], (float) transform[2], (float) transform[4],
15341534
// (float) transform[1], (float) transform[3], (float) transform[5]);
@@ -1575,6 +1575,12 @@ public void printMatrix() {
15751575
}
15761576

15771577

1578+
protected Matrix getMatrixImp() {
1579+
return parent.getSurfaceView().getMatrix();
1580+
// return canvas.getMatrix();
1581+
}
1582+
1583+
15781584

15791585
//////////////////////////////////////////////////////////////
15801586

@@ -1619,7 +1625,8 @@ public float screenX(float x, float y) {
16191625
}
16201626
screenPoint[0] = x;
16211627
screenPoint[1] = y;
1622-
canvas.getMatrix().mapPoints(screenPoint);
1628+
// canvas.getMatrix().mapPoints(screenPoint);
1629+
getMatrixImp().mapPoints(screenPoint);
16231630
return screenPoint[0];
16241631
}
16251632

@@ -1633,7 +1640,8 @@ public float screenY(float x, float y) {
16331640
}
16341641
screenPoint[0] = x;
16351642
screenPoint[1] = y;
1636-
canvas.getMatrix().mapPoints(screenPoint);
1643+
// canvas.getMatrix().mapPoints(screenPoint);
1644+
getMatrixImp().mapPoints(screenPoint);
16371645
return screenPoint[1];
16381646
}
16391647

@@ -2060,35 +2068,28 @@ public void set(int x, int y, PImage src) {
20602068
}
20612069

20622070
if (src.bitmap == null) {
2063-
// hopefully this will do the work to figure out what's on/offscreen
2064-
// in spite of the offset and stride that's been provided
2065-
canvas.drawBitmap(src.pixels, 0, src.width,
2066-
x, y, src.width, src.height, false, null);
2067-
// hasAlpha is set to false since we don't want blending.
2068-
// however that may be incorrect if it winds up copying only the RGB
2069-
// (without the A) portion of the pixels.
2070-
2071-
} else { // src.bitmap != null
2072-
if (src.width != src.bitmap.getWidth() ||
2073-
src.height != src.bitmap.getHeight()) {
2071+
src.bitmap = Bitmap.createBitmap(src.width, src.height, Config.ARGB_8888);
2072+
src.modified = true;
2073+
}
2074+
if (src.width != src.bitmap.getWidth() ||
2075+
src.height != src.bitmap.getHeight()) {
2076+
src.bitmap.recycle();
2077+
src.bitmap = Bitmap.createBitmap(src.width, src.height, Config.ARGB_8888);
2078+
src.modified = true;
2079+
}
2080+
if (src.modified) {
2081+
if (!src.bitmap.isMutable()) {
20742082
src.bitmap.recycle();
20752083
src.bitmap = Bitmap.createBitmap(src.width, src.height, Config.ARGB_8888);
2076-
src.modified = true;
20772084
}
2078-
if (src.modified) {
2079-
if (!src.bitmap.isMutable()) {
2080-
src.bitmap.recycle();
2081-
src.bitmap = Bitmap.createBitmap(src.width, src.height, Config.ARGB_8888);
2082-
}
2083-
src.bitmap.setPixels(src.pixels, 0, src.width, 0, 0, src.width, src.height);
2084-
src.modified = false;
2085-
}
2086-
// set() happens in screen coordinates, so need to clear the ctm
2087-
canvas.save(Canvas.MATRIX_SAVE_FLAG);
2088-
canvas.setMatrix(null); // set to identity
2089-
canvas.drawBitmap(src.bitmap, x, y, null);
2090-
canvas.restore();
2085+
src.bitmap.setPixels(src.pixels, 0, src.width, 0, 0, src.width, src.height);
2086+
src.modified = false;
20912087
}
2088+
// set() happens in screen coordinates, so need to clear the ctm
2089+
canvas.save(Canvas.MATRIX_SAVE_FLAG);
2090+
canvas.setMatrix(null); // set to identity
2091+
canvas.drawBitmap(src.bitmap, x, y, null);
2092+
canvas.restore();
20922093
}
20932094

20942095

0 commit comments

Comments
 (0)