Ejemplo n.º 1
0
  private void updateImages() {
    mainIcon.setIcon(model.getCharacterToken().getIcon());
    if (model.getCharacter().getGameObject().hasThisAttribute(CharacterInfoCard.NO_INVERT_ICON)) {
      ImageIcon icon = model.getCharacter().getFullSizedIcon();
      BufferedImage bi =
          new BufferedImage(
              icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_3BYTE_BGR);
      Graphics big = bi.getGraphics();
      big.setColor(Color.black);
      big.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
      big.drawImage(icon.getImage(), 0, 0, null);
      invertedIcon.setIcon(new ImageIcon(bi));
    } else {
      invertedIcon.setIcon(getInvertedIcon());
    }

    repaint();
  }
Ejemplo n.º 2
0
  private void initComponents() {
    setSize(250, 250);
    setLayout(new BorderLayout());
    JPanel icons = new JPanel(new GridLayout(1, 2));
    mainIcon = new JLabel(model.getCharacterToken().getIcon());
    icons.add(mainIcon);
    invertedIcon = new JLabel("");
    icons.add(invertedIcon);
    add(icons, "Center");

    JPanel buttons = new JPanel(new GridLayout(4, 1));
    invertImageOption =
        new JCheckBox(
            "Invert Icon on Black",
            !model
                .getCharacter()
                .getGameObject()
                .hasThisAttribute(CharacterInfoCard.NO_INVERT_ICON));
    invertImageOption.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            if (invertImageOption.isSelected()) {
              model
                  .getCharacter()
                  .getGameObject()
                  .removeThisAttribute(CharacterInfoCard.NO_INVERT_ICON);
            } else {
              model
                  .getCharacter()
                  .getGameObject()
                  .setThisAttribute(CharacterInfoCard.NO_INVERT_ICON);
            }
            updateImages();
          }
        });
    buttons.add(invertImageOption);
    editIconButton = new JButton("Load Symbol");
    editIconButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            loadSymbol();
          }
        });
    buttons.add(editIconButton);
    generateIconButton = new JButton("Generate Symbol");
    generateIconButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            generateSymbol();
          }
        });
    buttons.add(generateIconButton);
    doneButton = new JButton("Done");
    doneButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            setVisible(false);
          }
        });
    buttons.add(doneButton);
    add(buttons, "South");

    updateImages();
  }