从右到左绘制图像
我必须在图表上绘制彩色地图。问题是我的图表的原点可以在右侧或左侧。 可以从右向左画吗?
double origin_x = xPositionToPixel(0.0);
double origin_y = yPositionToPixel(0.0);
BufferedImage image = new BufferedImage(values.length, values[0].length, BufferedImage.TYPE_INT_ARGB);
Graphics2D gImg = (Graphics2D)image.getGraphics();
for (int i = 0; i < values.length; i++) {
Double[] dValues = values[i];
for (int j = 0; j < dValues.length; j++) {
double value = dValues[j];
gImg.setColor(ColorMap.getPixelColor(value));
gImg.drawRect(i, j, 1, 1);
}
}
g2.drawImage(image, (int)origin_x + 1, (int)origin_y + 1, null);
I have to draw a colored map on a graph. The problem is that my graph can have its origin at the right or the left.
Is it possible to draw from right to left ?
double origin_x = xPositionToPixel(0.0);
double origin_y = yPositionToPixel(0.0);
BufferedImage image = new BufferedImage(values.length, values[0].length, BufferedImage.TYPE_INT_ARGB);
Graphics2D gImg = (Graphics2D)image.getGraphics();
for (int i = 0; i < values.length; i++) {
Double[] dValues = values[i];
for (int j = 0; j < dValues.length; j++) {
double value = dValues[j];
gImg.setColor(ColorMap.getPixelColor(value));
gImg.drawRect(i, j, 1, 1);
}
}
g2.drawImage(image, (int)origin_x + 1, (int)origin_y + 1, null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,使用 AffineTransform并反转 x 轴:
Yes, use an AffineTransform and invert the x axis: