glimmer-dsl-swing 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +71 -50
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/glimmer-dsl-swing.gemspec +0 -0
- data/lib/glimmer/dsl/swing/property_expression.rb +1 -1
- data/lib/glimmer/swing/component_proxy.rb +9 -4
- data/lib/glimmer/swing/shape_proxy.rb +28 -1
- data/samples/hello/hello_shapes.rb +29 -20
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 839a9058d2f94757fbe185bb825a23a10fd840a0588b9e5f4fc44ede4ca4d511
|
4
|
+
data.tar.gz: efd4e9dead40a0076b3d3647657fe27642101f498b7381efe7cf554a3d440d51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88bb15d31a9186a28d5e321f35080ff97bcdd055747f815e672c481e549dfd2076d9202f905e76d18528aead464ef8b5e920dd65a90736debedbc986a0cfecc7
|
7
|
+
data.tar.gz: 1bda4d359a7974c9f8ee4fa4ca21ef30d6f833038b200dc0de8acd7e8dae7b9ac717a15d984a48d7e8c4cb7d600b440259b57e3f8d9dde23c50cc745c4716d0c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.4
|
4
|
+
|
5
|
+
- Support setting `stroke` attribute in shapes
|
6
|
+
- Rename `draw_color` and `fill_color` to `draw_paint` and `fill_paint` to be consistent with `java.awt.Graphics2D` terminology (while keeping older syntax as an alias/alternative)
|
7
|
+
- Enable antialiasing by default on Java 2D graphics
|
8
|
+
- Update Hello, Shapes! to take advantage of `stroke`
|
9
|
+
|
3
10
|
## 0.0.3
|
4
11
|
|
5
12
|
- Support `observe` keyword for observing model attributes to update the View
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Swing 0.0.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Swing 0.0.4
|
2
2
|
## JRuby Swing Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-swing)
|
4
4
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
5
|
|
6
6
|
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Swing](https://docs.oracle.com/javase/tutorial/uiswing/) enables building desktop applications with [Java Swing](https://docs.oracle.com/javase/tutorial/uiswing/), [Java AWT](https://docs.oracle.com/javase/8/docs/technotes/guides/awt/index.html), [Java Foundation Classes](https://docs.oracle.com/javase/tutorial/uiswing/start/about.html) and [Java 2D](https://docs.oracle.com/javase/tutorial/2d/index.html) via [JRuby](https://www.jruby.org/).
|
7
7
|
|
8
|
-
There has been a great divide between two big GUI toolkits in Java
|
8
|
+
There has been a great divide between two big GUI toolkits in Java:
|
9
9
|
- [Eclipse SWT](https://www.eclipse.org/swt/)
|
10
10
|
- [Java Swing/AWT/JFC/2D](https://docs.oracle.com/javase/tutorial/uiswing/)
|
11
11
|
|
@@ -57,14 +57,14 @@ Note: On the Mac, if you have [Glimmer DSL for SWT](https://github.com/AndyObtiv
|
|
57
57
|
|
58
58
|
Run this command to install directly:
|
59
59
|
```
|
60
|
-
gem install glimmer-dsl-swing -v0.0.
|
60
|
+
gem install glimmer-dsl-swing -v0.0.4
|
61
61
|
```
|
62
62
|
|
63
63
|
### Option 2: Bundler
|
64
64
|
|
65
65
|
Add the following to `Gemfile`:
|
66
66
|
```
|
67
|
-
gem 'glimmer-dsl-swing', '0.0.
|
67
|
+
gem 'glimmer-dsl-swing', '0.0.4'
|
68
68
|
```
|
69
69
|
|
70
70
|
And, then run:
|
@@ -110,7 +110,7 @@ The Glimmer GUI DSL enables development of desktop graphical user interfaces in
|
|
110
110
|
|
111
111
|
1 - Keywords
|
112
112
|
|
113
|
-
You may declare any swing/awt component with its keyword, which is the underscored version of the class name. For example, `jframe` is the keyword for `javax.swing.JFrame` (`j_frame` is acceptable too)
|
113
|
+
You may declare any [swing](https://docs.oracle.com/javase/8/docs/api/javax/swing/package-summary.html)/[awt](https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html) component with its keyword, which is the underscored version of the class name. For example, `jframe` is the keyword for `javax.swing.JFrame` (`j_frame` is acceptable too)
|
114
114
|
|
115
115
|
Examples:
|
116
116
|
|
@@ -124,7 +124,7 @@ jlabel
|
|
124
124
|
|
125
125
|
You may pass any arguments that a [swing](https://docs.oracle.com/javase/8/docs/api/javax/swing/package-summary.html)/[awt](https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html) component constructor accepts to its Glimmer keyword.
|
126
126
|
|
127
|
-
Example `JFrame`, `
|
127
|
+
Example (`JFrame`, `JButton`, and `JLabel` have a constructor signature that accepts a string representing title or text):
|
128
128
|
|
129
129
|
```ruby
|
130
130
|
jframe('Hello, World!')
|
@@ -148,13 +148,13 @@ jframe('Hello, World!') {
|
|
148
148
|
}
|
149
149
|
```
|
150
150
|
|
151
|
-
The recommended style for the content block is
|
151
|
+
The recommended style for the content block is always curly braces `{}` to denote as View nesting code different from looping/conditional logic, which utilizes `do;end` instead.
|
152
152
|
|
153
153
|
Property arguments never have parentheses.
|
154
154
|
|
155
155
|
4 - Listeners
|
156
156
|
|
157
|
-
You may declare listeners with their event method name on the [swing](https://docs.oracle.com/javase/8/docs/api/javax/swing/package-summary.html)/[awt](https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html) listener class (these are the classes in the signatures of `AddXYZListener` methods on [swing](https://docs.oracle.com/javase/8/docs/api/javax/swing/package-summary.html)/[awt](https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html) component classes).
|
157
|
+
You may declare listeners with their `on_`-prefixed event method name on the [swing](https://docs.oracle.com/javase/8/docs/api/javax/swing/package-summary.html)/[awt](https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html) listener class (these are the classes in the signatures of `AddXYZListener` methods on [swing](https://docs.oracle.com/javase/8/docs/api/javax/swing/package-summary.html)/[awt](https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html) component classes).
|
158
158
|
|
159
159
|
For example, `JButton` has an `AddXYZListener` method called `AddActionListener`, which accepts an `ActionListener` class. That class has one event method: `actionPerformed`. In Glimmer, you simply underscore that and prefix with `on_`:
|
160
160
|
|
@@ -183,7 +183,7 @@ frame1 = jframe('Hello, World!') {
|
|
183
183
|
frame1.show
|
184
184
|
```
|
185
185
|
|
186
|
-
Despite `#show` being deprecated in the Java API, it is recommended to use `#show` instead of `visible=` in the Glimmer GUI DSL because it has less awkward syntax (it calls `visible=` behind the scenes to avoid the deprecated API). `#show` also invokes `pack` automatically on first run,
|
186
|
+
Despite `#show` being deprecated in the Java API, it is recommended to use `#show` instead of `visible=` in the Glimmer GUI DSL because it has less awkward syntax (it calls `visible=` behind the scenes to avoid the deprecated API). `#show` also invokes `pack` automatically on first run, utilizing `SwingUtilities.invokeLater`.
|
187
187
|
|
188
188
|
6 - Observe Model Attributes
|
189
189
|
|
@@ -249,7 +249,10 @@ For example, `Arc2D` becomes simply `arc`.
|
|
249
249
|
|
250
250
|
Glimmer utilizes the `Double` variation of shape classes.
|
251
251
|
|
252
|
-
Additionally, you can set
|
252
|
+
Additionally, you can set these shape properties:
|
253
|
+
- `draw_paint` (alias: `draw_color`): takes [`java.awt.Color`](https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html) rgba arguments to use color for drawing
|
254
|
+
- `fill_paint` (alias: `fill_color`): takes [`java.awt.Color`](https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html) rgba arguments to use color for filling
|
255
|
+
- `stroke`: takes [`java.awt.BasicStroke`](https://docs.oracle.com/javase/8/docs/api/java/awt/BasicStroke.html) line width and other arguments to use for drawing
|
253
256
|
|
254
257
|
Example:
|
255
258
|
|
@@ -262,45 +265,54 @@ jframe('Hello, Shapes!') {
|
|
262
265
|
minimum_size 400, 400
|
263
266
|
|
264
267
|
arc(40, 40, 90, 90, 30, 230, 0) {
|
265
|
-
|
266
|
-
|
268
|
+
fill_paint 255, 0, 0
|
269
|
+
draw_paint 0, 128, 255
|
270
|
+
stroke 3
|
267
271
|
}
|
268
272
|
|
269
273
|
arc(40, 140, 90, 90, 30, 230, 1) {
|
270
|
-
|
271
|
-
|
274
|
+
fill_paint 255, 0, 0
|
275
|
+
draw_paint 0, 128, 255
|
276
|
+
stroke 3
|
272
277
|
}
|
273
278
|
|
274
279
|
arc(40, 240, 90, 90, 30, 230, 2) {
|
275
|
-
|
276
|
-
|
280
|
+
fill_paint 255, 0, 0
|
281
|
+
draw_paint 0, 128, 255
|
282
|
+
stroke 3
|
277
283
|
}
|
278
284
|
|
279
|
-
|
280
|
-
|
281
|
-
|
285
|
+
rectangle(140, 40, 180, 90) {
|
286
|
+
fill_paint 255, 255, 0
|
287
|
+
draw_paint 255, 0, 0
|
288
|
+
stroke 3
|
282
289
|
}
|
283
290
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
round_rectangle(140, 240, 180, 90, 60, 40) {
|
290
|
-
fill_color r: 0, g: 255, b: 255
|
291
|
-
draw_color r: 255, g: 0, b: 0
|
291
|
+
round_rectangle(140, 140, 180, 90, 60, 40) {
|
292
|
+
fill_paint 255, 255, 0
|
293
|
+
draw_paint 255, 0, 0
|
294
|
+
stroke 3
|
292
295
|
}
|
293
296
|
|
297
|
+
ellipse(140, 240, 180, 90) {
|
298
|
+
fill_paint 255, 255, 0
|
299
|
+
draw_paint 255, 0, 0
|
300
|
+
stroke 3
|
301
|
+
}
|
302
|
+
|
294
303
|
line(180, 60, 280, 110) {
|
295
|
-
|
304
|
+
draw_paint 255, 0, 0
|
305
|
+
stroke 3
|
296
306
|
}
|
297
307
|
|
298
308
|
quad_curve(170, 60, 180, 90, 220, 100) {
|
299
|
-
|
309
|
+
draw_paint 0, 255, 0
|
310
|
+
stroke 3
|
300
311
|
}
|
301
312
|
|
302
313
|
cubic_curve(190, 60, 240, 40, 220, 80, 260, 70) {
|
303
|
-
|
314
|
+
draw_paint 0, 0, 255
|
315
|
+
stroke 3
|
304
316
|
}
|
305
317
|
}.show
|
306
318
|
```
|
@@ -453,45 +465,54 @@ jframe('Hello, Shapes!') {
|
|
453
465
|
minimum_size 400, 400
|
454
466
|
|
455
467
|
arc(40, 40, 90, 90, 30, 230, 0) {
|
456
|
-
|
457
|
-
|
468
|
+
fill_paint 255, 0, 0
|
469
|
+
draw_paint 0, 128, 255
|
470
|
+
stroke 3
|
458
471
|
}
|
459
472
|
|
460
473
|
arc(40, 140, 90, 90, 30, 230, 1) {
|
461
|
-
|
462
|
-
|
474
|
+
fill_paint 255, 0, 0
|
475
|
+
draw_paint 0, 128, 255
|
476
|
+
stroke 3
|
463
477
|
}
|
464
478
|
|
465
479
|
arc(40, 240, 90, 90, 30, 230, 2) {
|
466
|
-
|
467
|
-
|
480
|
+
fill_paint 255, 0, 0
|
481
|
+
draw_paint 0, 128, 255
|
482
|
+
stroke 3
|
468
483
|
}
|
469
484
|
|
470
|
-
|
471
|
-
|
472
|
-
|
485
|
+
rectangle(140, 40, 180, 90) {
|
486
|
+
fill_paint 255, 255, 0
|
487
|
+
draw_paint 255, 0, 0
|
488
|
+
stroke 3
|
473
489
|
}
|
474
490
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
round_rectangle(140, 240, 180, 90, 60, 40) {
|
481
|
-
fill_color r: 0, g: 255, b: 255
|
482
|
-
draw_color r: 255, g: 0, b: 0
|
491
|
+
round_rectangle(140, 140, 180, 90, 60, 40) {
|
492
|
+
fill_paint 255, 255, 0
|
493
|
+
draw_paint 255, 0, 0
|
494
|
+
stroke 3
|
483
495
|
}
|
484
496
|
|
497
|
+
ellipse(140, 240, 180, 90) {
|
498
|
+
fill_paint 255, 255, 0
|
499
|
+
draw_paint 255, 0, 0
|
500
|
+
stroke 3
|
501
|
+
}
|
502
|
+
|
485
503
|
line(180, 60, 280, 110) {
|
486
|
-
|
504
|
+
draw_paint 255, 0, 0
|
505
|
+
stroke 3
|
487
506
|
}
|
488
507
|
|
489
508
|
quad_curve(170, 60, 180, 90, 220, 100) {
|
490
|
-
|
509
|
+
draw_paint 0, 255, 0
|
510
|
+
stroke 3
|
491
511
|
}
|
492
512
|
|
493
513
|
cubic_curve(190, 60, 240, 40, 220, 80, 260, 70) {
|
494
|
-
|
514
|
+
draw_paint 0, 0, 255
|
515
|
+
stroke 3
|
495
516
|
}
|
496
517
|
}.show
|
497
518
|
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/bin/girb
CHANGED
File without changes
|
data/glimmer-dsl-swing.gemspec
CHANGED
Binary file
|
@@ -87,18 +87,23 @@ module Glimmer
|
|
87
87
|
attr_accessor :shape_proxies
|
88
88
|
|
89
89
|
def paint(g2)
|
90
|
+
rendering_hints = RenderingHints.new(RenderingHints::KEY_ANTIALIASING, RenderingHints::VALUE_ANTIALIAS_ON)
|
91
|
+
g2.set_rendering_hints(rendering_hints)
|
90
92
|
super(g2)
|
91
93
|
shape_proxies.each do |shape_proxy|
|
92
|
-
|
94
|
+
original_paint = g2.get_paint
|
95
|
+
original_stroke = g2.get_stroke
|
93
96
|
if shape_proxy.fill_color
|
94
|
-
g2.
|
97
|
+
g2.set_paint shape_proxy.fill_paint
|
95
98
|
g2.fill(shape_proxy)
|
96
99
|
end
|
97
100
|
if shape_proxy.draw_color
|
98
|
-
g2.
|
101
|
+
g2.set_stroke shape_proxy.stroke unless shape_proxy.stroke.nil?
|
102
|
+
g2.set_paint shape_proxy.draw_paint
|
99
103
|
g2.draw(shape_proxy)
|
100
104
|
end
|
101
|
-
g2.
|
105
|
+
g2.set_paint original_paint
|
106
|
+
g2.set_stroke original_stroke || BasicStroke.new
|
102
107
|
end
|
103
108
|
end
|
104
109
|
}
|
@@ -99,7 +99,6 @@ module Glimmer
|
|
99
99
|
end
|
100
100
|
|
101
101
|
attr_reader :parent_proxy, :original, :args, :keyword, :block
|
102
|
-
attr_accessor :draw_color, :fill_color
|
103
102
|
|
104
103
|
def initialize(parent, keyword, *args, &block)
|
105
104
|
@parent_proxy = parent
|
@@ -149,6 +148,34 @@ module Glimmer
|
|
149
148
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Swing::ShapeExpression.new, @keyword, &block)
|
150
149
|
end
|
151
150
|
|
151
|
+
def stroke=(*args)
|
152
|
+
@stroke = BasicStroke.new(*args)
|
153
|
+
end
|
154
|
+
|
155
|
+
def stroke
|
156
|
+
@stroke
|
157
|
+
end
|
158
|
+
|
159
|
+
def draw_paint=(*args)
|
160
|
+
@draw_paint = Color.new(*args)
|
161
|
+
end
|
162
|
+
alias draw_color= draw_paint=
|
163
|
+
|
164
|
+
def draw_paint
|
165
|
+
@draw_paint
|
166
|
+
end
|
167
|
+
alias draw_color draw_paint
|
168
|
+
|
169
|
+
def fill_paint=(*args)
|
170
|
+
@fill_paint = Color.new(*args)
|
171
|
+
end
|
172
|
+
alias fill_color= fill_paint=
|
173
|
+
|
174
|
+
def fill_paint
|
175
|
+
@fill_paint
|
176
|
+
end
|
177
|
+
alias fill_color fill_paint
|
178
|
+
|
152
179
|
private
|
153
180
|
|
154
181
|
def build
|
@@ -6,44 +6,53 @@ jframe('Hello, Shapes!') {
|
|
6
6
|
minimum_size 400, 400
|
7
7
|
|
8
8
|
arc(40, 40, 90, 90, 30, 230, 0) {
|
9
|
-
|
10
|
-
|
9
|
+
fill_paint 255, 0, 0
|
10
|
+
draw_paint 0, 128, 255
|
11
|
+
stroke 3
|
11
12
|
}
|
12
13
|
|
13
14
|
arc(40, 140, 90, 90, 30, 230, 1) {
|
14
|
-
|
15
|
-
|
15
|
+
fill_paint 255, 0, 0
|
16
|
+
draw_paint 0, 128, 255
|
17
|
+
stroke 3
|
16
18
|
}
|
17
19
|
|
18
20
|
arc(40, 240, 90, 90, 30, 230, 2) {
|
19
|
-
|
20
|
-
|
21
|
+
fill_paint 255, 0, 0
|
22
|
+
draw_paint 0, 128, 255
|
23
|
+
stroke 3
|
21
24
|
}
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
rectangle(140, 40, 180, 90) {
|
27
|
+
fill_paint 255, 255, 0
|
28
|
+
draw_paint 255, 0, 0
|
29
|
+
stroke 3
|
26
30
|
}
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
round_rectangle(140, 240, 180, 90, 60, 40) {
|
34
|
-
fill_color r: 0, g: 255, b: 255
|
35
|
-
draw_color r: 255, g: 0, b: 0
|
32
|
+
round_rectangle(140, 140, 180, 90, 60, 40) {
|
33
|
+
fill_paint 255, 255, 0
|
34
|
+
draw_paint 255, 0, 0
|
35
|
+
stroke 3
|
36
36
|
}
|
37
37
|
|
38
|
+
ellipse(140, 240, 180, 90) {
|
39
|
+
fill_paint 255, 255, 0
|
40
|
+
draw_paint 255, 0, 0
|
41
|
+
stroke 3
|
42
|
+
}
|
43
|
+
|
38
44
|
line(180, 60, 280, 110) {
|
39
|
-
|
45
|
+
draw_paint 255, 0, 0
|
46
|
+
stroke 3
|
40
47
|
}
|
41
48
|
|
42
49
|
quad_curve(170, 60, 180, 90, 220, 100) {
|
43
|
-
|
50
|
+
draw_paint 0, 255, 0
|
51
|
+
stroke 3
|
44
52
|
}
|
45
53
|
|
46
54
|
cubic_curve(190, 60, 240, 40, 220, 80, 260, 70) {
|
47
|
-
|
55
|
+
draw_paint 0, 0, 255
|
56
|
+
stroke 3
|
48
57
|
}
|
49
58
|
}.show
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,7 +202,6 @@ executables:
|
|
202
202
|
- girb
|
203
203
|
extensions: []
|
204
204
|
extra_rdoc_files:
|
205
|
-
- CHANGELOG.md
|
206
205
|
- LICENSE.txt
|
207
206
|
- README.md
|
208
207
|
files:
|
@@ -252,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
252
251
|
- !ruby/object:Gem::Version
|
253
252
|
version: '0'
|
254
253
|
requirements: []
|
255
|
-
rubygems_version: 3.
|
254
|
+
rubygems_version: 3.1.6
|
256
255
|
signing_key:
|
257
256
|
specification_version: 4
|
258
257
|
summary: Glimmer DSL for Swing
|