Libraryless. Click here for Pure Java version (5053L/29K).
1 | asclass Surface extends JPanel is IMeta { |
2 | public boolean clearSurface = true; |
3 | private boolean clearOnce; |
4 | |
5 | !include #1033864 // Meta mix-in |
6 | |
7 | Surface() { |
8 | setDoubleBuffered(false); |
9 | } |
10 | |
11 | Graphics2D createGraphics2D(int width, int height, Graphics g) { |
12 | Graphics2D g2 = (Graphics2D) g; |
13 | g2.setBackground(getBackground()); |
14 | if (clearSurface || clearOnce) { |
15 | g2.clearRect(0, 0, width, height); |
16 | clearOnce = false; |
17 | } |
18 | return g2; |
19 | } |
20 | |
21 | public abstract void render(int w, int h, Graphics2D g); |
22 | |
23 | public void paintImmediately(int x,int y,int w, int h) { |
24 | RepaintManager repaintManager = null; |
25 | boolean save = true; |
26 | if (!isDoubleBuffered()) { |
27 | repaintManager = RepaintManager.currentManager(this); |
28 | save = repaintManager.isDoubleBufferingEnabled(); |
29 | repaintManager.setDoubleBufferingEnabled(false); |
30 | } |
31 | super.paintImmediately(x, y, w, h); |
32 | |
33 | if (repaintManager != null) |
34 | repaintManager.setDoubleBufferingEnabled(save); |
35 | } |
36 | |
37 | public void paint(Graphics g) { |
38 | Dimension d = getSize(); |
39 | Graphics2D g2 = createGraphics2D(d.width, d.height, g); |
40 | render(d.width, d.height, g2); |
41 | g2.dispose(); |
42 | } |
43 | } |
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004554 |
Snippet name: | class Surface with imageType = 1 |
Eternal ID of this version: | #1004554/7 |
Text MD5: | 1577f2ca1c67b4ea98a71adc4782012c |
Transpilation MD5: | 98389272efeae306c83e79ba3d3fb3e0 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-10 20:27:46 |
Source code size: | 1219 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 640 / 6158 |
Version history: | 6 change(s) |
Referenced in: | [show references] |