我想我可能应该指出我是如何做到的-毕竟堆栈溢出也应该是一个存储库。在代码的早期是以下内容:
m_vis.setRendererFactory(new RendererFactory() { Renderer yAxisRenderer = new AxisRenderer(Constants.LEFT, Constants.TOP); Renderer xAxisRenderer = new AxisRenderer(Constants.CENTER, Constants.FAR_BOTTOM); Renderer barRenderer = new ShapeRenderer(); public Renderer getRenderer(VisualItem item) { return item.isInGroup("yAxis") ? yAxisRenderer : item.isInGroup("xAxis") ? xAxisRenderer : barRenderer; }});
我扩展了形状渲染器,以始终返回正确宽度和高度的矩形,并将其放置在应该位于其左侧的半格处。如果您想将杠铃放置在中间,则需要自己进行设置-预涂不会帮助您。
m_vis.setRendererFactory(new RendererFactory() { Renderer yAxisRenderer = new AxisRenderer(Constants.LEFT, Constants.TOP); Renderer xAxisRenderer = new AxisRenderer(Constants.CENTER, Constants.FAR_BOTTOM); Renderer barRenderer = new ShapeRenderer() { protected Shape getRawShape(VisualItem item) { double x = item.getX(); double y = item.getY(); if (Double.isNaN(x) || Double.isInfinite(x)) x = getInsets().left + axisWidth + totalBarWidth / 2; if (Double.isNaN(y) || Double.isInfinite(y)) y = 0; double width = totalBarWidth / (barCount + 1) - barGap; double height = getHeight() - getInsets().bottom - axisHeight - y; x -= width / 2; return rectangle(x, y, width, height); } }; public Renderer getRenderer(VisualItem item) { return item.isInGroup("yAxis") ? yAxisRenderer : item.isInGroup("xAxis") ? xAxisRenderer : barRenderer; }});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)