/** * Handles the pressing of a pathLbl button: display the file chooser * and update the path if a file is selected * * @param pathIdx */ private void chooseFile() { int returnVal = fileChooser.showOpenDialog(this); // Did the user choose valid input? if ((returnVal != JFileChooser.APPROVE_OPTION) || (fileChooser.getSelectedFile() == null)) { return; } // Get relative path String relativePath = Configuration.widgetsDir().toURI() .relativize(fileChooser.getSelectedFile().toURI()) .getPath(); // Set text path.setText(relativePath); }
private ImageIcon loadIcon(String path) throws MalformedURLException { ImageIcon icon; java.net.URI imgURL; File file; file = new MegaMekFile(Configuration.widgetsDir(), path).getFile(); imgURL = file.toURI(); icon = new ImageIcon(imgURL.toURL()); if (!file.exists()){ System.err.println("MegaMekBorder Error: icon doesn't exist: " + file.getAbsolutePath()); iconsLoaded = false; } return icon; }
/** * Handles the pressing of a pathLbl button: display the file chooser * and update the path if a file is selected * * @param pathIdx */ private void chooseFile(int pathIdx) { int returnVal = fileChooser.showOpenDialog(this); // Did the user choose valid input? if ((returnVal != JFileChooser.APPROVE_OPTION) || (fileChooser.getSelectedFile() == null)) { return; } // Get relative path String relativePath = Configuration.widgetsDir().toURI() .relativize(fileChooser.getSelectedFile().toURI()) .getPath(); // Set text path.get(pathIdx).getDocument().removeDocumentListener(this); path.get(pathIdx).setText(relativePath); path.get(pathIdx).getDocument().addDocumentListener(this); }
/** * Constructor for BorderElements that only have one image (like * corners). The option to tile the image is not present, nor are the * add and remove buttons. * * @param elementName * @param imgPath */ BorderElement(UnitDisplaySpecPanel udPanel, String elementName, String imgPath) { super(new GridBagLayout()); this.udPanel = udPanel; setBorder(BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder(), elementName, TitledBorder.LEFT, TitledBorder.TOP)); pathLbl = new JButton( Messages.getString("SkinEditor.Path")); //$NON-NLS-1$ pathLbl.setMargin(new Insets(1, 1, 1, 1)); pathLbl.setToolTipText(Messages.getString( "SkinEditor.PathToolTip", //$NON-NLS-1$ new Object[] { Configuration.widgetsDir().getPath() })); pathLbl.addActionListener(this); path = new JTextField(imgPath, TEXTFIELD_COLS); path.getDocument().addDocumentListener(this); layoutPanel(); }
newPathLbl.setToolTipText(Messages.getString( "SkinEditor.PathToolTip", //$NON-NLS-1$ new Object[] { Configuration.widgetsDir().getPath() })); newPathLbl.addActionListener(this); pathLbl.add(newPathLbl);
newPathLbl.setToolTipText(Messages.getString( "SkinEditor.PathToolTip", //$NON-NLS-1$ new Object[] { Configuration.widgetsDir().getPath() })); newPathLbl.addActionListener(this);
iconsLoaded = false; java.net.URI imgURL = new MegaMekFile(Configuration.widgetsDir(), spec.backgrounds.get(0)).getFile().toURI(); backgroundIcon = new ImageIcon(imgURL.toURL()); imgURL = new MegaMekFile(Configuration.widgetsDir(), spec.backgrounds.get(1)).getFile().toURI(); backgroundPressedIcon = new ImageIcon(imgURL.toURL());
/** * Test method for {@link megamek.common.Configuration#widgetsDir()}. */ @Test public final void testWidgetsDir() { assertEquals(new File(Configuration.imagesDir(), "widgets").toString(), Configuration.widgetsDir().toString()); } }
public UnitOverview(ClientGUI clientgui) { this.clientgui = clientgui; fm = clientgui.getFontMetrics(FONT); Toolkit toolkit = clientgui.getToolkit(); scrollUp = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "scrollUp.gif").toString()); //$NON-NLS-1$ PMUtil.setImage(scrollUp, clientgui); scrollDown = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "scrollDown.gif").toString()); //$NON-NLS-1$ PMUtil.setImage(scrollDown, clientgui); pageUp = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "pageUp.gif").toString()); //$NON-NLS-1$ PMUtil.setImage(pageUp, clientgui); pageDown = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "pageDown.gif").toString()); //$NON-NLS-1$ PMUtil.setImage(pageDown, clientgui); visible = GUIPreferences.getInstance().getShowUnitOverview(); }
private void setBackGround() { UnitDisplaySkinSpecification udSpec = SkinXMLHandler .getUnitDisplaySkin(); Image tile = comp.getToolkit() .getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec .getBackgroundTile()).toString()); PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec.getMechOutline()) .toString()); PMUtil.setImage(tile, comp); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_CENTER | BackGroundDrawer.HALIGN_CENTER; BackGroundDrawer bgd = new BackGroundDrawer(tile, b); bgDrawers.addElement(bgd); }
private void setBackGround() { UnitDisplaySkinSpecification udSpec = SkinXMLHandler .getUnitDisplaySkin(); Image tile = comp.getToolkit() .getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec .getBackgroundTile()).toString()); PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec.getMechOutline()) .toString()); PMUtil.setImage(tile, comp); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_CENTER | BackGroundDrawer.HALIGN_CENTER; BackGroundDrawer bgd = new BackGroundDrawer(tile, b); bgDrawers.addElement(bgd); }
private void setBackGround() { UnitDisplaySkinSpecification udSpec = SkinXMLHandler .getUnitDisplaySkin(); Image tile = comp.getToolkit() .getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec .getBackgroundTile()).toString()); PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec.getMechOutline()) .toString()); PMUtil.setImage(tile, comp); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_CENTER | BackGroundDrawer.HALIGN_CENTER; BackGroundDrawer bgd = new BackGroundDrawer(tile, b); bgDrawers.addElement(bgd); }
private void setBackGround() { UnitDisplaySkinSpecification udSpec = SkinXMLHandler .getUnitDisplaySkin(); Image tile = comp.getToolkit() .getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec .getBackgroundTile()).toString()); PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage( new MegaMekFile(Configuration.widgetsDir(), udSpec.getMechOutline()) .toString()); PMUtil.setImage(tile, comp); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_CENTER | BackGroundDrawer.HALIGN_CENTER; BackGroundDrawer bgd = new BackGroundDrawer(tile, b); bgDrawers.addElement(bgd); }
.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBackgroundTile()).toString()); PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getLeftLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getRightLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); .getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopRightCorner()).toString());
.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBackgroundTile()).toString()); PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getLeftLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getRightLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); .getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopRightCorner()).toString());
.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBackgroundTile()).toString()); PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getLeftLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getRightLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); .getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopRightCorner()).toString());
Image tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBackgroundTile()).toString()); //$NON-NLS-1$ PMUtil.setImage(tile, comp); int b = BackGroundDrawer.TILING_BOTH; tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLine()).toString()); //$NON-NLS-1$ PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getLeftLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getRightLine()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getBottomLeftCorner()).toString()); PMUtil.setImage(tile, comp); bgDrawers.addElement(new BackGroundDrawer(tile, b)); tile = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getTopRightCorner()).toString());
upbutton = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), FILENAME_BUTTON_UP).toString()); PMUtil.setImage(upbutton, client); downbutton = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), FILENAME_BUTTON_DOWN).toString()); PMUtil.setImage(downbutton, client); minbutton = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), FILENAME_BUTTON_MINIMISE).toString()); PMUtil.setImage(minbutton, client); maxbutton = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), FILENAME_BUTTON_MAXIMISE).toString()); PMUtil.setImage(maxbutton, client); resizebutton = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), FILENAME_BUTTON_RESIZE).toString()); PMUtil.setImage(resizebutton, client);
private void setAreas() { FontMetrics fm = comp.getFontMetrics(FONT_VALUE); battleArmorImage = comp.getToolkit().getImage( new MegaMekFile(Configuration.widgetsDir(), "battle_armor.gif").toString()); //$NON-NLS-1$ PMUtil.setImage(battleArmorImage, comp); for (int i = 0; i < BattleArmor.BA_MAX_MEN; i++) { int shiftY = i * stepY; unitAreas[i] = new PMPicArea(battleArmorImage); unitAreas[i].translate(0, shiftY); content.addArea(unitAreas[i]); armorImage[i] = comp.createImage(105, 12); armorAreas[i] = new PMPicArea(armorImage[i]); armorAreas[i].translate(45, shiftY + 12); content.addArea(armorAreas[i]); armorLabels[i] = new PMValueLabel(fm, Color.red.brighter()); armorLabels[i].moveTo(160, shiftY + 24); content.addArea(armorLabels[i]); } }
private void setAreas() { int stepX = 30; int stepY = 42; infImage = comp.getToolkit().getImage(new MegaMekFile(Configuration.widgetsDir(), "inf.gif").toString()); //$NON-NLS-1$ PMUtil.setImage(infImage, comp); for (int i = 0; i < Infantry.INF_PLT_MAX_MEN; i++) { int shiftX = (i % 5) * stepX; int shiftY = (i / 5) * stepY; areas[i] = new PMPicArea(infImage); areas[i].translate(shiftX, shiftY); content.addArea(areas[i]); } FontMetrics fm = comp.getFontMetrics(FONT_VALUE); armorLabel = new PMValueLabel(fm, Color.white); armorLabel.setValue(Messages.getString( "InfantryMapSet.Armor") + "XXXXXXXXXXXX"); //$NON-NLS-1$//$NON-NLS-2$ Dimension d = armorLabel.getSize(); content.translate(0, d.height + 5); armorLabel.moveTo(0, d.height); content.addArea(armorLabel); label = new PMValueLabel(fm, Color.white); label.setValue(Messages.getString( "InfantryMapSet.InfantryPlatoon", new Object[] { "00" })); //$NON-NLS-1$//$NON-NLS-2$ d = label.getSize(); content.translate(0, d.height + 5); label.moveTo(0, d.height); content.addArea(label); }