Transpiled version (37269L) is out of date.
1 | sclass JTickerView is Swingable { |
2 | settable S coin; |
3 | settable int h = 200; |
4 | settable TickerSequence ticker; |
5 | settable AbstractTickerPainter painter; |
6 | settable IImageSurfaceMaker imageSurfaceMaker = -> imageSurfaceWithToolTip(); |
7 | settable ImageSurface isTicker; |
8 | settable G22TradingStrategy strategy; |
9 | settable double cellSize = naN(); |
10 | settable bool center; |
11 | |
12 | JSlider timeZoomSlider = jSlider(1, 10, 1); |
13 | ReliableSingleThread rstPaint = rst(l0 repaintImpl); |
14 | |
15 | event settingUpPainter(AbstractTickerPainter painter); |
16 | |
17 | *() {} |
18 | *(TickerSequence *ticker) {} |
19 | |
20 | swappable void makePainter() { |
21 | painter if null = new TickerGraphPainter; |
22 | painter.w(300*intFromSlider(timeZoomSlider)).h(h); |
23 | painter.ticker(ticker); |
24 | painter.drawPercentLines(false); |
25 | if (!isNaN(cellSize)) |
26 | painter.cellSize(cellSize); |
27 | /*painter.horizontalRange( |
28 | transformBetweenDoubleRanges (varTimeZoom get) (zeroToOne) (painter horizontalRangeForTicker ticker) |
29 | zoomedRange <- transformBetweenDoubleRanges (varTimeZoom get) (zeroToOne) (toDoubleRange < ticker timeRange) |
30 | painter verticalRange < |
31 | painter verticalRangeForTicker (ticker subSequenceByTimestamps (lround < zoomedRange start) (lround < zoomedRange end)) |
32 | */ |
33 | |
34 | //painter.additionalObjects.add(g -> painter drawTimeGrid(g, 60)); |
35 | |
36 | if (strategy != null) |
37 | for (p : strategy.closedPositions()) |
38 | painter.positions.add(TradingPosition.fromStrategy(p)); |
39 | |
40 | settingUpPainter(painter); |
41 | } |
42 | |
43 | void repaintImpl() { |
44 | makePainter(); |
45 | isTicker.setImage(painter.render()); |
46 | } |
47 | |
48 | cachedVisualize { |
49 | if (isTicker == null) isTicker = imageSurfaceMaker.newImageSurface(); |
50 | onChange(timeZoomSlider, rstPaint); |
51 | rstPaint.trigger(); |
52 | ret jCenteredSection(str(ticker), |
53 | centerAndSouthWithMargin( |
54 | jMinHeight(h, center ? jscroll_horizontal_center_borderless(isTicker) : jscroll_horizontal_borderless(isTicker)), |
55 | withLabel("Time zoom:", timeZoomSlider) |
56 | )); |
57 | } |
58 | |
59 | selfType defaultTimeZoom(int zoom) { |
60 | setSliderValue(timeZoomSlider, zoom); |
61 | this; |
62 | } |
63 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1036260 |
Snippet name: | JTickerView |
Eternal ID of this version: | #1036260/34 |
Text MD5: | 0ffadbb09bc5e434737029c27fadc9a5 |
Author: | stefan |
Category: | javax / trading / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-03-13 13:58:02 |
Source code size: | 2154 bytes / 63 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 216 / 395 |
Version history: | 33 change(s) |
Referenced in: | [show references] |