setIcon(ICON_NAME, false);
}
@Override
public void actionPerformed(ActionEvent e) {
PackerOutput output = factory.createTextureAtlas();
if (output.atlasSizes.isEmpty()) {
Dialogs.warning(parent,
Messages.getString("ViewAtlasAction.ZERO_ATLASES")); //$NON-NLS-1$
return;
}
if (output.packedImages.isEmpty()) {
Dialogs.warning(parent,
Messages.getString("ViewAtlasAction.ZERO_IMAGES")); //$NON-NLS-1$
return;
}
JTabbedPane atlasTabs = new JTabbedPane(JTabbedPane.TOP);
for (Entry<Integer, Dimension> atlasEntry : output.atlasSizes
.entrySet()) {
Collection<ImageData> textures = new LinkedList<ImageData>();
int index = atlasEntry.getKey();
for (ImageData eachData : output.packedImages) {
if (eachData.atlas == index) {
textures.add(eachData);
}
}
Dimension size = atlasEntry.getValue();
String sizeStr = String.format(
Messages.getString("ViewAtlasAction.ATLAS_SIZE_FORMAT"), //$NON-NLS-1$
size.width, size.height);
LayoutManager atlasLayout = new BorderLayout(4, 4);
JPanel atlasPane = new JPanel(atlasLayout);
TextureAtlas atlas = new TextureAtlas(size.width, size.height,
textures);
JLabel sizeLabel = new JLabel(sizeStr);
atlasPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
atlasPane.add(atlas, BorderLayout.CENTER);
atlasPane.add(sizeLabel, BorderLayout.PAGE_END);
atlasTabs
.add(String.valueOf(output.getAtlasName(index)), atlasPane);
}
JOptionPane.showMessageDialog(parent, atlasTabs,
Messages.getString("ViewAtlasAction.TITLE"), //$NON-NLS-1$
JOptionPane.PLAIN_MESSAGE);