use of javax.vecmath.Point3i in project WorldPainter by Captain-Chaos.
the class EditObjectAttributes method editOffset.
private void editOffset() {
if (objects.size() > 1) {
return;
}
WPObject object = objects.iterator().next();
Point3i offset = offsets.get(object);
OffsetEditor dialog = new OffsetEditor(this, (offset != null) ? offset : new Point3i(), object, colourScheme);
dialog.setVisible(true);
if (!dialog.isCancelled()) {
offset = dialog.getOffset();
offsets.put(object, offset);
String offsetStr = "<html><u>" + offset.x + ", " + offset.y + ", " + offset.z + "</u></html>";
labelOffset.setText(offsetStr);
}
}
use of javax.vecmath.Point3i in project WorldPainter by Captain-Chaos.
the class OffsetViewer method paintComponent.
@Override
protected void paintComponent(Graphics g) {
if ((object == null) || (offset == null)) {
return;
}
Graphics2D g2 = (Graphics2D) g;
int baseLine = getHeight() * 3 / 4;
int middle = getWidth() / 2;
Point3i dim = object.getDimensions();
switch(direction) {
case X_ASC:
for (int y = 0; y <= Math.min(-offset.y, dim.y - 1); y++) {
for (int x = 0; x < dim.x; x++) {
for (int z = 0; z < dim.z; z++) {
if (object.getMask(x, y, z)) {
paintBlock(g2, baseLine, middle, x + offset.x, z + offset.z, -offset.y - y, object.getMaterial(x, y, z));
}
}
}
}
g2.drawImage(IMAGE_X_ASC, middle + 10, getHeight() - IMAGE_X_ASC.getHeight() - 2, null);
break;
case Y_ASC:
for (int x = 0; x <= Math.min(-offset.x, dim.x - 1); x++) {
for (int y = 0; y < dim.y; y++) {
for (int z = 0; z < dim.z; z++) {
if (object.getMask(x, y, z)) {
paintBlock(g2, baseLine, middle, y + offset.y, z + offset.z, -offset.x - x, object.getMaterial(x, y, z));
}
}
}
}
g2.drawImage(IMAGE_Y_ASC, middle + 10, getHeight() - IMAGE_Y_ASC.getHeight() - 2, null);
break;
case X_DESC:
for (int y = dim.y - 1; y >= Math.max(-offset.y, 0); y--) {
for (int x = 0; x < dim.x; x++) {
for (int z = 0; z < dim.z; z++) {
if (object.getMask(x, y, z)) {
paintBlock(g2, baseLine, middle, -x - offset.x, z + offset.z, y - -offset.y, object.getMaterial(x, y, z));
}
}
}
}
g2.drawImage(IMAGE_X_DESC, middle - IMAGE_X_DESC.getWidth() - 10, getHeight() - IMAGE_X_DESC.getHeight() - 2, null);
break;
case Y_DESC:
for (int x = dim.x - 1; x >= Math.max(-offset.x, 0); x--) {
for (int y = 0; y < dim.y; y++) {
for (int z = 0; z < dim.z; z++) {
if (object.getMask(x, y, z)) {
paintBlock(g2, baseLine, middle, -y - offset.y, z + offset.z, x - -offset.x, object.getMaterial(x, y, z));
}
}
}
}
g2.drawImage(IMAGE_Y_DESC, middle - IMAGE_Y_DESC.getWidth() - 10, getHeight() - IMAGE_Y_DESC.getHeight() - 2, null);
break;
}
g2.setColor(Color.BLACK);
g2.setStroke(STROKE);
g2.drawRect(middle - 8, baseLine - 8, 16, 16);
g2.drawLine(middle - 8, baseLine + 8, 0, baseLine + 8);
g2.drawLine(middle + 7, baseLine + 8, getWidth() - 1, baseLine + 8);
}
Aggregations