JLabel labelGapX = new JLabel(
Messages.getString("ImportTiledTextureAction.LABEL_GAP_X")); //$NON-NLS-1$
JLabel labelGapY = new JLabel(
Messages.getString("ImportTiledTextureAction.LABEL_GAP_Y")); //$NON-NLS-1$
SpinnerModel modelOffsetX = new SpinnerNumberModel(propOffsetX, 0,
65536, 1);
SpinnerModel modelOffsetY = new SpinnerNumberModel(propOffsetY, 0,
65536, 1);
SpinnerModel modelWidth = new SpinnerNumberModel(propWidth, 1, 65536, 1);
SpinnerModel modelHeight = new SpinnerNumberModel(propHeight, 1, 65536,
1);
SpinnerModel modelGapX = new SpinnerNumberModel(propGapX, 0, 65536, 1);
SpinnerModel modelGapY = new SpinnerNumberModel(propGapY, 0, 65536, 1);
JSpinner spinOffsetX = new JSpinner(modelOffsetX);
JSpinner spinOffsetY = new JSpinner(modelOffsetY);
JSpinner spinWidth = new JSpinner(modelWidth);
JSpinner spinHeight = new JSpinner(modelHeight);
JSpinner spinGapX = new JSpinner(modelGapX);
JSpinner spinGapY = new JSpinner(modelGapY);
JCheckBox checkCrop = new JCheckBox(
Messages.getString("ImportTiledTextureAction.LABEL_CROP"), propCrop); //$NON-NLS-1$
JCheckBox checkTransparent = new JCheckBox(
Messages.getString("ImportTiledTextureAction.LABEL_TRANSPARENT"), propTransparent); //$NON-NLS-1$
JCheckBox checkColored = new JCheckBox(
Messages.getString("ImportTiledTextureAction.LABEL_COLORED"), propColored); //$NON-NLS-1$
// -----------------------------------------------
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
// @formatter:off
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
.addComponent(labelOffset)
.addComponent(labelSize)
.addComponent(labelGap)
)
.addGroup(layout.createParallelGroup(Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(spinOffsetX)
.addComponent(labelOffsetX)
.addComponent(spinOffsetY)
.addComponent(labelOffsetY)
.addContainerGap(0, Short.MAX_VALUE)
)
.addGroup(layout.createSequentialGroup()
.addComponent(spinWidth)
.addComponent(labelWidth)
.addComponent(spinHeight)
.addComponent(labelHeight)
.addContainerGap(0, Short.MAX_VALUE)
)
.addGroup(layout.createSequentialGroup()
.addComponent(spinGapX)
.addComponent(labelGapX)
.addComponent(spinGapY)
.addComponent(labelGapY)
.addContainerGap(0, Short.MAX_VALUE)
)
.addComponent(checkCrop)
.addComponent(checkTransparent)
.addComponent(checkColored)
)
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createBaselineGroup(false, false)
.addComponent(labelOffset)
.addComponent(spinOffsetX)
.addComponent(labelOffsetX)
.addComponent(spinOffsetY)
.addComponent(labelOffsetY)
)
.addGroup(layout.createBaselineGroup(false, false)
.addComponent(labelSize)
.addComponent(spinWidth)
.addComponent(labelWidth)
.addComponent(spinHeight)
.addComponent(labelHeight)
)
.addGroup(layout.createBaselineGroup(false, false)
.addComponent(labelGap)
.addComponent(spinGapX)
.addComponent(labelGapX)
.addComponent(spinGapY)
.addComponent(labelGapY)
)
.addComponent(checkCrop)
.addComponent(checkTransparent)
.addComponent(checkColored)
);
// @formatter:on
layout.linkSize(SwingConstants.HORIZONTAL, spinOffsetX, spinOffsetY);
layout.linkSize(SwingConstants.HORIZONTAL, spinWidth, spinHeight);
layout.linkSize(SwingConstants.HORIZONTAL, spinGapX, spinGapY);
// -----------------------------------------------
int result = JOptionPane
.showConfirmDialog(
parent,
pane,
Messages.getString("ImportTiledTextureAction.TITLE"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$
JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.NO_OPTION) {
return;
}
File file = Dialogs.getImage(parent);
if (file == null) {
return;
}
BufferedImage image;
try {
image = ImageIO.read(file);
} catch (IOException e) {
Dialogs.error(pane, e.getMessage());
return;
}
propOffsetX = (Integer) modelOffsetX.getValue();
propOffsetY = (Integer) modelOffsetY.getValue();
propWidth = (Integer) modelWidth.getValue();
propHeight = (Integer) modelHeight.getValue();
propGapX = (Integer) modelGapX.getValue();
propGapY = (Integer) modelGapY.getValue();
propCrop = checkCrop.isSelected();
propTransparent = checkTransparent.isSelected();
propColored = checkColored.isSelected();