sclass JTickerView is Swingable { settable S coin; settable int h = 200; settable TickerSequence ticker; settable AbstractTickerPainter painter; settable IImageSurfaceMaker imageSurfaceMaker = -> imageSurfaceWithToolTip(); settable ImageSurface isTicker; settable G22TradingStrategy strategy; settable double cellSize = naN(); settable bool center; JSlider timeZoomSlider = jSlider(1, 10, 1); ReliableSingleThread rstPaint = rst(l0 repaintImpl); event settingUpPainter(AbstractTickerPainter painter); *() {} *(TickerSequence *ticker) {} swappable void makePainter() { painter if null = new TickerGraphPainter; painter.w(300*intFromSlider(timeZoomSlider)).h(h); painter.ticker(ticker); painter.drawPercentLines(false); if (!isNaN(cellSize)) painter.cellSize(cellSize); /*painter.horizontalRange( transformBetweenDoubleRanges (varTimeZoom get) (zeroToOne) (painter horizontalRangeForTicker ticker) zoomedRange <- transformBetweenDoubleRanges (varTimeZoom get) (zeroToOne) (toDoubleRange < ticker timeRange) painter verticalRange < painter verticalRangeForTicker (ticker subSequenceByTimestamps (lround < zoomedRange start) (lround < zoomedRange end)) */ //painter.additionalObjects.add(g -> painter drawTimeGrid(g, 60)); if (strategy != null) for (p : strategy.closedPositions()) painter.positions.add(TradingPosition.fromStrategy(p)); settingUpPainter(painter); } void repaintImpl() { makePainter(); isTicker.setImage(painter.render()); } cachedVisualize { if (isTicker == null) isTicker = imageSurfaceMaker.newImageSurface(); onChange(timeZoomSlider, rstPaint); rstPaint.trigger(); ret jCenteredSection(str(ticker), centerAndSouthWithMargin( jMinHeight(h, center ? jscroll_horizontal_center_borderless(isTicker) : jscroll_horizontal_borderless(isTicker)), withLabel("Time zoom:", timeZoomSlider) )); } selfType defaultTimeZoom(int zoom) { setSliderValue(timeZoomSlider, zoom); this; } }