picrate 2.3.0-java → 2.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/Gemfile +1 -1
  4. data/README.md +2 -2
  5. data/Rakefile +1 -1
  6. data/docs/.gitignore +1 -0
  7. data/docs/_classes/{app_render → gfx_render}/app_render.md +5 -5
  8. data/docs/_methods/{noise_mode.md → noise_modes.md} +9 -21
  9. data/docs/_posts/2018-05-06-install_jruby.md +5 -5
  10. data/docs/_posts/2019-11-11-getting_started_buster.md +1 -1
  11. data/lib/picrate/app.rb +3 -7
  12. data/lib/picrate/native_folder.rb +1 -1
  13. data/lib/picrate/version.rb +1 -1
  14. data/lib/{picrate-2.3.0.jar → picrate-2.5.0.jar} +0 -0
  15. data/{lib → library/pdf}/itextpdf-5.5.13.2.jar +0 -0
  16. data/library/pdf/pdf.rb +1 -0
  17. data/library/svg/batik-all-1.14.jar +0 -0
  18. data/library/svg/svg.rb +7 -0
  19. data/picrate.gemspec +4 -3
  20. data/pom.rb +19 -10
  21. data/pom.xml +19 -6
  22. data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
  23. data/src/main/java/monkstone/PicrateLibrary.java +2 -0
  24. data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
  25. data/src/main/java/monkstone/noise/OpenSimplex2F.java +62 -29
  26. data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -1106
  27. data/src/main/java/monkstone/vecmath/GfxRender.java +10 -11
  28. data/src/main/java/monkstone/vecmath/JRender.java +7 -7
  29. data/src/main/java/monkstone/vecmath/ShapeRender.java +3 -4
  30. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +28 -40
  31. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +30 -45
  32. data/src/main/java/processing/awt/PImageAWT.java +1 -1
  33. data/src/main/java/processing/awt/ShimAWT.java +1 -1
  34. data/src/main/java/processing/core/PApplet.java +1 -92
  35. data/src/main/java/processing/core/PImage.java +14 -14
  36. data/src/main/java/processing/opengl/PShader.java +0 -6
  37. data/src/main/java/processing/pdf/PGraphicsPDF.java +61 -139
  38. data/src/main/java/processing/svg/PGraphicsSVG.java +378 -0
  39. data/test/noise_test.rb +17 -0
  40. data/test/respond_to_test.rb +0 -1
  41. data/test/test_helper.rb +1 -1
  42. data/vendors/Rakefile +1 -1
  43. metadata +21 -32
  44. data/src/main/java/japplemenubar/JAppleMenuBar.java +0 -96
  45. data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  46. data/src/main/java/monkstone/complex/JComplex.java +0 -252
  47. data/src/main/java/monkstone/noise/FastTerrain.java +0 -874
  48. data/src/main/java/monkstone/noise/Noise.java +0 -90
  49. data/src/main/java/monkstone/noise/NoiseGenerator.java +0 -75
  50. data/src/main/java/monkstone/noise/NoiseMode.java +0 -28
  51. data/src/main/java/monkstone/noise/SmoothTerrain.java +0 -1099
  52. data/src/main/java/monkstone/vecmath/AppRender.java +0 -88
  53. data/src/main/java/monkstone/vecmath/package-info.java +0 -20
  54. data/src/main/java/monkstone/vecmath/vec2/package-info.java +0 -6
  55. data/src/main/java/monkstone/vecmath/vec3/package-info.java +0 -6
@@ -3,20 +3,19 @@ package monkstone.vecmath;
3
3
  import processing.core.PGraphics;
4
4
 
5
5
  /**
6
- *
7
6
  *
8
7
  * @author Martin Prout
9
8
  */
10
9
  public class GfxRender implements JRender {
11
10
 
12
- final PGraphics g;
11
+ final PGraphics graphics;
13
12
 
14
13
  /**
15
14
  *
16
- * @param gfx PGraphics
15
+ * @param graphics PGraphics
17
16
  */
18
- public GfxRender(final PGraphics gfx) {
19
- this.g = gfx;
17
+ public GfxRender(final PGraphics graphics) {
18
+ this.graphics = graphics;
20
19
  }
21
20
 
22
21
  /**
@@ -26,7 +25,7 @@ public class GfxRender implements JRender {
26
25
  */
27
26
  @Override
28
27
  public void vertex(double x, double y) {
29
- g.vertex((float) x, (float) y);
28
+ graphics.vertex((float) x, (float) y);
30
29
  }
31
30
 
32
31
  /**
@@ -36,7 +35,7 @@ public class GfxRender implements JRender {
36
35
  */
37
36
  @Override
38
37
  public void curveVertex(double x, double y) {
39
- g.curveVertex((float) x, (float) y);
38
+ graphics.curveVertex((float) x, (float) y);
40
39
  }
41
40
 
42
41
  /**
@@ -47,7 +46,7 @@ public class GfxRender implements JRender {
47
46
  */
48
47
  @Override
49
48
  public void vertex(double x, double y, double z) {
50
- g.vertex((float) x, (float) y, (float) z);
49
+ graphics.vertex((float) x, (float) y, (float) z);
51
50
  }
52
51
 
53
52
  /**
@@ -58,7 +57,7 @@ public class GfxRender implements JRender {
58
57
  */
59
58
  @Override
60
59
  public void normal(double x, double y, double z) {
61
- g.normal((float) x, (float) y, (float) z);
60
+ graphics.normal((float) x, (float) y, (float) z);
62
61
  }
63
62
 
64
63
  /**
@@ -71,7 +70,7 @@ public class GfxRender implements JRender {
71
70
  */
72
71
  @Override
73
72
  public void vertex(double x, double y, double z, double u, double v) {
74
- g.vertex((float) x, (float) y, (float) z, (float) u, (float) v);
73
+ graphics.vertex((float) x, (float) y, (float) z, (float) u, (float) v);
75
74
  }
76
75
 
77
76
  /**
@@ -82,6 +81,6 @@ public class GfxRender implements JRender {
82
81
  */
83
82
  @Override
84
83
  public void curveVertex(double x, double y, double z) {
85
- g.curveVertex((float) x, (float) y, (float) z);
84
+ graphics.curveVertex((float) x, (float) y, (float) z);
86
85
  }
87
86
  }
@@ -1,7 +1,6 @@
1
1
  package monkstone.vecmath;
2
2
 
3
3
  /**
4
- *
5
4
  *
6
5
  * @author Martin Prout
7
6
  */
@@ -12,14 +11,14 @@ public interface JRender {
12
11
  * @param x double
13
12
  * @param y double
14
13
  */
15
- public void vertex(double x, double y);
14
+ void vertex(double x, double y);
16
15
 
17
16
  /**
18
17
  *
19
18
  * @param x double
20
19
  * @param y double
21
20
  */
22
- public void curveVertex(double x, double y);
21
+ void curveVertex(double x, double y);
23
22
 
24
23
  /**
25
24
  *
@@ -27,7 +26,7 @@ public interface JRender {
27
26
  * @param y double
28
27
  * @param z double
29
28
  */
30
- public void vertex(double x, double y, double z);
29
+ void vertex(double x, double y, double z);
31
30
 
32
31
  /**
33
32
  *
@@ -37,7 +36,7 @@ public interface JRender {
37
36
  * @param u double
38
37
  * @param v double
39
38
  */
40
- public void vertex(double x, double y, double z, double u, double v);
39
+ void vertex(double x, double y, double z, double u, double v);
41
40
 
42
41
  /**
43
42
  *
@@ -45,7 +44,7 @@ public interface JRender {
45
44
  * @param y double
46
45
  * @param z double
47
46
  */
48
- public void curveVertex(double x, double y, double z);
47
+ void curveVertex(double x, double y, double z);
49
48
 
50
49
  /**
51
50
  *
@@ -53,5 +52,6 @@ public interface JRender {
53
52
  * @param y double
54
53
  * @param z double
55
54
  */
56
- public void normal(double x, double y, double z);
55
+ void normal(double x, double y, double z);
57
56
  }
57
+
@@ -3,7 +3,6 @@ package monkstone.vecmath;
3
3
  import processing.core.PShape;
4
4
 
5
5
  /**
6
- *
7
6
  *
8
7
  * @author Martin Prout
9
8
  */
@@ -29,7 +28,7 @@ public class ShapeRender implements JRender {
29
28
  public void vertex(double x, double y) {
30
29
  shape.vertex((float) x, (float) y);
31
30
  }
32
-
31
+
33
32
  /**
34
33
  *
35
34
  * @param x double
@@ -37,7 +36,7 @@ public class ShapeRender implements JRender {
37
36
  */
38
37
  @Override
39
38
  public void curveVertex(double x, double y) {
40
- shape.curveVertex((float) x, (float) y);
39
+ throw new UnsupportedOperationException("Not implemented for this renderer");
41
40
  }
42
41
 
43
42
  /**
@@ -74,7 +73,7 @@ public class ShapeRender implements JRender {
74
73
  public void vertex(double x, double y, double z, double u, double v) {
75
74
  shape.vertex((float) x, (float) y, (float) z, (float) u, (float) v);
76
75
  }
77
-
76
+
78
77
  /**
79
78
  *
80
79
  * @param x double
@@ -20,7 +20,7 @@ package monkstone.vecmath.vec2;
20
20
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
21
  *
22
22
  * fastAtan2 algorithm from https://github.com/libgdx/libgdx (Apache 2.0 license)
23
- */
23
+ */
24
24
  import org.jruby.Ruby;
25
25
  import org.jruby.RubyArray;
26
26
  import org.jruby.RubyClass;
@@ -40,7 +40,7 @@ import monkstone.vecmath.JRender;
40
40
  * @author Martin Prout
41
41
  */
42
42
  @JRubyClass(name = "Vec2D")
43
- public class Vec2 extends RubyObject {
43
+ public final class Vec2 extends RubyObject {
44
44
 
45
45
  static final double EPSILON = 9.999999747378752e-05; // matches processing.org EPSILON
46
46
  private static final long serialVersionUID = -2950154560223211646L;
@@ -57,18 +57,10 @@ public class Vec2 extends RubyObject {
57
57
  vec2Cls.defineAnnotatedMethods(Vec2.class);
58
58
  }
59
59
 
60
- /**
61
- *
62
- * @return x value :double
63
- */
64
60
  public double javax() {
65
61
  return jx;
66
62
  }
67
63
 
68
- /**
69
- *
70
- * @return y value :double
71
- */
72
64
  public double javay() {
73
65
  return jy;
74
66
  }
@@ -81,7 +73,7 @@ public class Vec2 extends RubyObject {
81
73
  * @return new Vec2 object (ruby)
82
74
  */
83
75
  @JRubyMethod(name = "new", meta = true, rest = true)
84
- public static final IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
76
+ public static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
85
77
  Vec2 vec2 = (Vec2) ((RubyClass) klazz).allocate();
86
78
  vec2.init(context, args);
87
79
  return vec2;
@@ -99,16 +91,16 @@ public class Vec2 extends RubyObject {
99
91
  void init(ThreadContext context, IRubyObject... args) {
100
92
  int count = args.length;
101
93
  if (count == 2) {
102
- jx = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
103
- jy = (args[1] instanceof RubyFloat) ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
94
+ jx = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
95
+ jy = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
104
96
  } // allow ruby ducktyping in constructor
105
97
  if (count == 1) {
106
98
  if (!(args[0].respondsTo("x"))) {
107
99
  throw context.runtime.newTypeError(args[0].getType() + " doesn't respond_to :x & :y");
108
100
  }
109
- jx = ((args[0].callMethod(context, "x")) instanceof RubyFloat)
101
+ jx = args[0].callMethod(context, "x") instanceof RubyFloat
110
102
  ? ((RubyFloat) args[0].callMethod(context, "x")).getValue() : ((RubyFixnum) args[0].callMethod(context, "x")).getDoubleValue();
111
- jy = ((args[0].callMethod(context, "y")) instanceof RubyFloat)
103
+ jy = args[0].callMethod(context, "y") instanceof RubyFloat
112
104
  ? ((RubyFloat) args[0].callMethod(context, "y")).getValue() : ((RubyFixnum) args[0].callMethod(context, "y")).getDoubleValue();
113
105
  }
114
106
  }
@@ -170,10 +162,10 @@ public class Vec2 extends RubyObject {
170
162
  Ruby runtime = context.runtime;
171
163
  if (key instanceof RubySymbol) {
172
164
  if (key == RubySymbol.newSymbol(runtime, "x")) {
173
- jx = (value instanceof RubyFloat)
165
+ jx = value instanceof RubyFloat
174
166
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
175
167
  } else if (key == RubySymbol.newSymbol(runtime, "y")) {
176
- jy = (value instanceof RubyFloat)
168
+ jy = value instanceof RubyFloat
177
169
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
178
170
  }
179
171
  } else {
@@ -232,7 +224,7 @@ public class Vec2 extends RubyObject {
232
224
  } else {
233
225
  throw runtime.newTypeError("argument should be Vec2D");
234
226
  }
235
- double result = Math.hypot((jx - b.jx), (jy - b.jy));
227
+ double result = Math.hypot(jx - b.jx, jy - b.jy);
236
228
  return runtime.newFloat(result);
237
229
  }
238
230
 
@@ -326,7 +318,7 @@ public class Vec2 extends RubyObject {
326
318
 
327
319
  public IRubyObject op_mul(ThreadContext context, IRubyObject other) {
328
320
  Ruby runtime = context.runtime;
329
- double scalar = (other instanceof RubyFloat)
321
+ double scalar = other instanceof RubyFloat
330
322
  ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
331
323
  return Vec2.rbNew(context, this.getMetaClass(),
332
324
  new IRubyObject[]{runtime.newFloat(jx * scalar),
@@ -343,7 +335,7 @@ public class Vec2 extends RubyObject {
343
335
 
344
336
  public IRubyObject op_div(ThreadContext context, IRubyObject other) {
345
337
  Ruby runtime = context.runtime;
346
- double scalar = (other instanceof RubyFloat)
338
+ double scalar = other instanceof RubyFloat
347
339
  ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
348
340
  if (Math.abs(scalar) < Vec2.EPSILON) {
349
341
  return this;
@@ -408,10 +400,8 @@ public class Vec2 extends RubyObject {
408
400
 
409
401
  public IRubyObject set_mag(ThreadContext context, IRubyObject scalar, Block block) {
410
402
  double new_mag = scalar.toJava(Double.class);
411
- if (block.isGiven()) {
412
- if (!(boolean) block.yield(context, scalar).toJava(Boolean.class)) {
413
- return this;
414
- }
403
+ if (block.isGiven() && !block.yield(context, scalar).toJava(Boolean.class)) {
404
+ return this;
415
405
  }
416
406
  double current = 0;
417
407
  if (Math.abs(jx) > EPSILON && Math.abs(jy) > EPSILON) {
@@ -497,7 +487,7 @@ public class Vec2 extends RubyObject {
497
487
  @JRubyMethod(name = "from_angle", meta = true)
498
488
  public static IRubyObject from_angle(ThreadContext context, IRubyObject klazz, IRubyObject scalar) {
499
489
  Ruby runtime = context.runtime;
500
- double angle = (scalar instanceof RubyFloat)
490
+ double angle = scalar instanceof RubyFloat
501
491
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
502
492
  return Vec2.rbNew(context, klazz, new IRubyObject[]{
503
493
  runtime.newFloat(Math.cos(angle)),
@@ -528,10 +518,10 @@ public class Vec2 extends RubyObject {
528
518
  */
529
519
  @JRubyMethod(name = "rotate!")
530
520
  public IRubyObject rotate_bang(ThreadContext context, IRubyObject scalar) {
531
- double theta = (scalar instanceof RubyFloat)
521
+ double theta = scalar instanceof RubyFloat
532
522
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
533
- double x = (jx * Math.cos(theta) - jy * Math.sin(theta));
534
- double y = (jx * Math.sin(theta) + jy * Math.cos(theta));
523
+ double x = jx * Math.cos(theta) - jy * Math.sin(theta);
524
+ double y = jx * Math.sin(theta) + jy * Math.cos(theta);
535
525
  jx = x;
536
526
  jy = y;
537
527
  return this;
@@ -546,7 +536,7 @@ public class Vec2 extends RubyObject {
546
536
  @JRubyMethod(name = "rotate")
547
537
  public IRubyObject rotate(ThreadContext context, IRubyObject scalar) {
548
538
  Ruby runtime = context.runtime;
549
- double theta = (scalar instanceof RubyFloat)
539
+ double theta = scalar instanceof RubyFloat
550
540
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
551
541
  IRubyObject[] ary = new IRubyObject[]{
552
542
  runtime.newFloat(jx * Math.cos(theta) - jy * Math.sin(theta)),
@@ -567,9 +557,9 @@ public class Vec2 extends RubyObject {
567
557
  throw runtime.newSyntaxError("Check syntax");
568
558
  }
569
559
  Vec2 vec = (Vec2) args[0].toJava(Vec2.class);
570
- double scalar = (args[1] instanceof RubyFloat)
560
+ double scalar = args[1] instanceof RubyFloat
571
561
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
572
- assert (scalar >= 0 && scalar < 1.0) :
562
+ assert scalar >= 0 && scalar < 1.0 :
573
563
  "Lerp value " + scalar + " out of range 0..1.0";
574
564
  return Vec2.rbNew(context, this.getMetaClass(), new IRubyObject[]{
575
565
  runtime.newFloat(jx + (vec.jx - jx) * scalar),
@@ -589,9 +579,9 @@ public class Vec2 extends RubyObject {
589
579
  throw runtime.newSyntaxError("Check syntax");
590
580
  }
591
581
  Vec2 vec = (Vec2) args[0].toJava(Vec2.class);
592
- double scalar = (args[1] instanceof RubyFloat)
582
+ double scalar = args[1] instanceof RubyFloat
593
583
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
594
- assert (scalar >= 0 && scalar < 1.0) :
584
+ assert scalar >= 0 && scalar < 1.0 :
595
585
  "Lerp value " + scalar + " out of range 0..1.0";
596
586
  jx += (vec.jx - jx) * scalar;
597
587
  jy += (vec.jy - jy) * scalar;
@@ -752,10 +742,8 @@ public class Vec2 extends RubyObject {
752
742
  }
753
743
  if (obj instanceof Vec2) {
754
744
  final Vec2 other = (Vec2) obj;
755
- if ((Double.compare(jx, (Double) other.jx) == 0)
756
- && (Double.compare(jy, (Double) other.jy) == 0)) {
757
- return true;
758
- }
745
+ return Double.compare(jx, (Double) other.jx) == 0
746
+ && Double.compare(jy, (Double) other.jy) == 0;
759
747
  }
760
748
  return false;
761
749
  }
@@ -774,8 +762,8 @@ public class Vec2 extends RubyObject {
774
762
  }
775
763
  if (other instanceof Vec2) {
776
764
  Vec2 v = (Vec2) other.toJava(Vec2.class);
777
- if ((Double.compare(jx, (Double) v.jx) == 0)
778
- && (Double.compare(jy, (Double) v.jy) == 0)) {
765
+ if (Double.compare(jx, (Double) v.jx) == 0
766
+ && Double.compare(jy, (Double) v.jy) == 0) {
779
767
  return runtime.newBoolean(true);
780
768
  }
781
769
  }
@@ -801,7 +789,7 @@ public class Vec2 extends RubyObject {
801
789
  double diff = jx - v.jx;
802
790
  if ((diff < 0 ? -diff : diff) > Vec2.EPSILON) {
803
791
  return runtime.newBoolean(false);
804
- }
792
+ }
805
793
  diff = jy - v.jy;
806
794
  return runtime.newBoolean((diff < 0 ? -diff : diff) < Vec2.EPSILON);
807
795
  }
@@ -1,12 +1,12 @@
1
1
  package monkstone.vecmath.vec3;
2
2
 
3
3
  /*
4
- * Copyright (c) 2018-21 Martin Prout
4
+ * Copyright (c) 2015-20 Martin Prout
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public
7
+ * modify it under the terms of the GNU Lesser General Public
8
8
  * License as published by the Free Software Foundation; either
9
- * version 3.0 of the License, or (at your option) any later version.
9
+ * version 2.1 of the License, or (at your option) any later version.
10
10
  *
11
11
  * http://creativecommons.org/licenses/LGPL/2.1/
12
12
  *
@@ -15,7 +15,7 @@ package monkstone.vecmath.vec3;
15
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
16
  * Lesser General Public License for more details.
17
17
  *
18
- * You should have received a copy of the GNU General Public
18
+ * You should have received a copy of the GNU Lesser General Public
19
19
  * License along with this library; if not, write to the Free Software
20
20
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
21
  */
@@ -35,7 +35,6 @@ import monkstone.vecmath.JRender;
35
35
  import monkstone.vecmath.vec2.Vec2;
36
36
 
37
37
  /**
38
- *
39
38
  *
40
39
  * @author Martin Prout
41
40
  */
@@ -66,7 +65,7 @@ public final class Vec3 extends RubyObject {
66
65
  * @return new Vec3 object (ruby)
67
66
  */
68
67
  @JRubyMethod(name = "new", meta = true, rest = true)
69
- public final static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
68
+ public static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
70
69
  Vec3 vec = (Vec3) ((RubyClass) klazz).allocate();
71
70
  vec.init(context, args);
72
71
  return vec;
@@ -84,27 +83,27 @@ public final class Vec3 extends RubyObject {
84
83
  void init(ThreadContext context, IRubyObject... args) {
85
84
  int count = args.length;
86
85
  if (count >= 2) {
87
- jx = (args[0] instanceof RubyFloat)
86
+ jx = args[0] instanceof RubyFloat
88
87
  ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
89
- jy = (args[1] instanceof RubyFloat)
88
+ jy = args[1] instanceof RubyFloat
90
89
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
91
90
  }
92
91
  if (count == 3) {
93
- jz = (args[2] instanceof RubyFloat)
92
+ jz = args[2] instanceof RubyFloat
94
93
  ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
95
94
  } // allow ruby ducktyping in constructor
96
95
  if (count == 1) {
97
96
  if (!(args[0].respondsTo("x"))) {
98
97
  throw context.runtime.newTypeError(args[0].getType() + " doesn't respond_to :x & :y");
99
98
  }
100
- jx = ((args[0].callMethod(context, "x")) instanceof RubyFloat)
99
+ jx = (args[0].callMethod(context, "x")) instanceof RubyFloat
101
100
  ? ((RubyFloat) args[0].callMethod(context, "x")).getValue() : ((RubyFixnum) args[0].callMethod(context, "x")).getDoubleValue();
102
- jy = ((args[0].callMethod(context, "y")) instanceof RubyFloat)
101
+ jy = (args[0].callMethod(context, "y")) instanceof RubyFloat
103
102
  ? ((RubyFloat) args[0].callMethod(context, "y")).getValue() : ((RubyFixnum) args[0].callMethod(context, "y")).getDoubleValue();
104
103
  if (!(args[0].respondsTo("z"))) {
105
104
  return;
106
105
  } // allow promotion from 2D to 3D, sets jz = 0
107
- jz = ((args[0].callMethod(context, "z")) instanceof RubyFloat) ? ((RubyFloat) args[0].callMethod(context, "z")).getValue() : ((RubyFixnum) args[0].callMethod(context, "z")).getDoubleValue();
106
+ jz = (args[0].callMethod(context, "z")) instanceof RubyFloat ? ((RubyFloat) args[0].callMethod(context, "z")).getValue() : ((RubyFixnum) args[0].callMethod(context, "z")).getDoubleValue();
108
107
  }
109
108
  }
110
109
 
@@ -148,11 +147,7 @@ public final class Vec3 extends RubyObject {
148
147
  */
149
148
  @JRubyMethod(name = "x=")
150
149
  public IRubyObject setX(ThreadContext context, IRubyObject other) {
151
- if (other instanceof RubyFloat) {
152
- jx = ((RubyFloat) other).getValue();
153
- } else {
154
- jx = ((RubyFixnum) other).getDoubleValue();
155
- }
150
+ jx = other instanceof RubyFloat ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
156
151
  return other;
157
152
  }
158
153
 
@@ -164,11 +159,7 @@ public final class Vec3 extends RubyObject {
164
159
  */
165
160
  @JRubyMethod(name = "y=")
166
161
  public IRubyObject setY(ThreadContext context, IRubyObject other) {
167
- if (other instanceof RubyFloat) {
168
- jy = ((RubyFloat) other).getValue();
169
- } else {
170
- jy = ((RubyFixnum) other).getDoubleValue();
171
- }
162
+ jy = other instanceof RubyFloat ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
172
163
  return other;
173
164
  }
174
165
 
@@ -180,11 +171,7 @@ public final class Vec3 extends RubyObject {
180
171
  */
181
172
  @JRubyMethod(name = "z=")
182
173
  public IRubyObject setZ(ThreadContext context, IRubyObject other) {
183
- if (other instanceof RubyFloat) {
184
- jz = ((RubyFloat) other).getValue();
185
- } else {
186
- jz = ((RubyFixnum) other).getDoubleValue();
187
- }
174
+ jz = other instanceof RubyFloat ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
188
175
  return other;
189
176
  }
190
177
 
@@ -223,13 +210,13 @@ public final class Vec3 extends RubyObject {
223
210
  Ruby runtime = context.runtime;
224
211
  if (key instanceof RubySymbol) {
225
212
  if (key == RubySymbol.newSymbol(runtime, "x")) {
226
- jx = (value instanceof RubyFloat)
213
+ jx = value instanceof RubyFloat
227
214
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
228
215
  } else if (key == RubySymbol.newSymbol(runtime, "y")) {
229
- jy = (value instanceof RubyFloat)
216
+ jy = value instanceof RubyFloat
230
217
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
231
218
  } else if (key == RubySymbol.newSymbol(runtime, "z")) {
232
- jz = (value instanceof RubyFloat)
219
+ jz = value instanceof RubyFloat
233
220
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
234
221
  } else {
235
222
  throw runtime.newIndexError("invalid key");
@@ -369,7 +356,7 @@ public final class Vec3 extends RubyObject {
369
356
  @JRubyMethod(name = "*", required = 1)
370
357
  public IRubyObject op_mul(ThreadContext context, IRubyObject scalar) {
371
358
  Ruby runtime = context.runtime;
372
- double multi = (scalar instanceof RubyFloat)
359
+ double multi = scalar instanceof RubyFloat
373
360
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
374
361
  return Vec3.rbNew(context, this.getMetaClass(), new IRubyObject[]{
375
362
  runtime.newFloat(jx * multi),
@@ -386,7 +373,7 @@ public final class Vec3 extends RubyObject {
386
373
  @JRubyMethod(name = "/", required = 1)
387
374
  public IRubyObject op_div(ThreadContext context, IRubyObject scalar) {
388
375
  Ruby runtime = context.runtime;
389
- double divisor = (scalar instanceof RubyFloat)
376
+ double divisor = scalar instanceof RubyFloat
390
377
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
391
378
  if (Math.abs(divisor) < Vec3.EPSILON) {
392
379
  return this;
@@ -428,12 +415,10 @@ public final class Vec3 extends RubyObject {
428
415
  */
429
416
  @JRubyMethod(name = "set_mag")
430
417
  public IRubyObject set_mag(ThreadContext context, IRubyObject scalar, Block block) {
431
- if (block.isGiven()) {
432
- if (!(boolean) block.yield(context, scalar).toJava(Boolean.class)) {
433
- return this;
434
- }
418
+ if (block.isGiven() && !block.yield(context, scalar).toJava(Boolean.class)) {
419
+ return this;
435
420
  }
436
- double new_mag = (scalar instanceof RubyFloat)
421
+ double new_mag = scalar instanceof RubyFloat
437
422
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
438
423
  double current = Math.sqrt(jx * jx + jy * jy + jz * jz);
439
424
  if (current > EPSILON) {
@@ -599,9 +584,9 @@ public final class Vec3 extends RubyObject {
599
584
  double u = 0;
600
585
  double v = 0;
601
586
  if (count == 3) {
602
- u = (args[1] instanceof RubyFloat)
587
+ u = args[1] instanceof RubyFloat
603
588
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
604
- v = (args[2] instanceof RubyFloat)
589
+ v = args[2] instanceof RubyFloat
605
590
  ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
606
591
  }
607
592
  if (count == 2) {
@@ -663,9 +648,9 @@ public final class Vec3 extends RubyObject {
663
648
  }
664
649
  if (obj instanceof Vec3) {
665
650
  final Vec3 other = (Vec3) obj;
666
- if ((Double.compare(jx, (Double) other.jx) == 0)
667
- && (Double.compare(jy, (Double) other.jy) == 0)
668
- && (Double.compare(jz, (Double) other.jz) == 0)) {
651
+ if (Double.compare(jx, (Double) other.jx) == 0
652
+ && Double.compare(jy, (Double) other.jy) == 0
653
+ && Double.compare(jz, (Double) other.jz) == 0) {
669
654
  return true;
670
655
  }
671
656
 
@@ -687,9 +672,9 @@ public final class Vec3 extends RubyObject {
687
672
  }
688
673
  if (other instanceof Vec3) {
689
674
  Vec3 v = (Vec3) other.toJava(Vec3.class);
690
- if ((Double.compare(jx, (Double) v.jx) == 0)
691
- && (Double.compare(jy, (Double) v.jy) == 0)
692
- && (Double.compare(jz, (Double) v.jz) == 0)) {
675
+ if (Double.compare(jx, (Double) v.jx) == 0
676
+ && Double.compare(jy, (Double) v.jy) == 0
677
+ && Double.compare(jz, (Double) v.jz) == 0) {
693
678
  return runtime.newBoolean(true);
694
679
  }
695
680
 
@@ -262,7 +262,7 @@ public class PImageAWT extends PImage {
262
262
  * Use ImageIO functions from Java 1.4 and later to handle image save.
263
263
  * Various formats are supported, typically jpeg, png, bmp, and wbmp.
264
264
  * To get a list of the supported formats for writing, use: <BR>
265
- * <TT>println(javax.imageio.ImageIO.getReaderFormatNames())</TT>
265
+ * <code>println(javax.imageio.ImageIO.getReaderFormatNames())</code>
266
266
  *
267
267
  * @path The path to which the file should be written.
268
268
  */
@@ -354,7 +354,7 @@ public class ShimAWT implements PConstants {
354
354
  * Use ImageIO functions from Java 1.4 and later to handle image save.
355
355
  * Various formats are supported, typically jpeg, png, bmp, and wbmp.
356
356
  * To get a list of the supported formats for writing, use: <BR>
357
- * <TT>println(javax.imageio.ImageIO.getReaderFormatNames())</TT>
357
+ * <code>println(javax.imageio.ImageIO.getReaderFormatNames())</code>
358
358
  */
359
359
  static protected boolean saveImageIO(PImage image, String path) throws IOException {
360
360
  try {