Exemplo n.º 1
0
 public TextTool() {
   try {
     setIcon(
         new ImageIcon(ImageUtil.getImage("net/rptools/maptool/client/image/tool/text-blue.png")));
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
 }
Exemplo n.º 2
0
 private JToggleButton createButton(
     final String icon, final String offIcon, final OptionPanel panel, String tooltip) {
   final JToggleButton button = new JToggleButton();
   button.setToolTipText(tooltip);
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           if (button.isSelected()) {
             panel.activate();
             ((CardLayout) optionPanel.getLayout()).show(optionPanel, icon);
           }
         }
       });
   try {
     button.setIcon(new ImageIcon(ImageUtil.getImage(offIcon)));
     button.setSelectedIcon(new ImageIcon(ImageUtil.getImage(icon)));
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
   optionPanel.add(panel, icon);
   buttonGroup.add(button);
   return button;
 }
Exemplo n.º 3
0
  public GridTool() {
    try {
      setIcon(new ImageIcon(ImageUtil.getImage("net/rptools/maptool/client/image/grid.gif")));
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
    // Create the control panel
    controlPanel = new FormPanel("net/rptools/maptool/client/ui/forms/adjustGridControlPanel.xml");
    controlPanel.setBorder(BorderFactory.createLineBorder(Color.black));

    gridSizeSpinner = controlPanel.getSpinner("gridSize");
    gridSizeSpinner.setModel(new SpinnerNumberModel());
    gridSizeSpinner.addChangeListener(new UpdateGridListener());

    gridOffsetXTextField = controlPanel.getTextField("offsetX");
    gridOffsetXTextField.addKeyListener(new UpdateGridListener());

    gridOffsetYTextField = controlPanel.getTextField("offsetY");
    gridOffsetYTextField.addKeyListener(new UpdateGridListener());

    gridSecondDimensionLabel = (JETALabel) controlPanel.getLabel("gridSecondDimensionLabel");
    gridSecondDimension = controlPanel.getTextField("gridSecondDimension");
    gridSecondDimension.addFocusListener(new UpdateGridListener());

    colorWell = (JETAColorWell) controlPanel.getComponentByName("colorWell");
    colorWell.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            copyControlPanelToGrid();
          }
        });

    JButton closeButton = (JButton) controlPanel.getComponentByName("closeButton");
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resetTool();
            //				Lee: just to make the light sources snap to their owners after the tool is closed
            Zone z = MapTool.getFrame().getCurrentZoneRenderer().getZone();
            z.putTokens(z.getTokens());
          }
        });
    zoomSlider = (JSlider) controlPanel.getComponentByName("zoomSlider");
    zoomSlider.setMinimum(0);
    zoomSlider.setMaximum(zoomSliderStopCount);
    ZoomChangeListener zoomListener = new ZoomChangeListener();
    zoomSlider.addChangeListener(zoomListener);
    zoomSlider.addMouseListener(zoomListener);
  }
Exemplo n.º 4
0
  private Asset createAssetFromIcon(ImageIcon icon) {
    if (icon == null) return null;

    // Make sure there is a buffered image for it
    Image image = icon.getImage();
    if (!(image instanceof BufferedImage)) {
      image =
          new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), Transparency.TRANSLUCENT);
      Graphics2D g = ((BufferedImage) image).createGraphics();
      icon.paintIcon(null, g, 0, 0);
    }
    // Create the asset
    Asset asset = null;
    try {
      asset = new Asset(name, ImageUtil.imageToBytes((BufferedImage) image));
      if (!AssetManager.hasAsset(asset)) AssetManager.putAsset(asset);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return asset;
  }