Beispiel #1
0
  /**
   * Draws the entity on the map editor.
   *
   * @param g graphic context
   * @param zoom zoom of the image (for example, 1: unchanged, 2: zoom of 200%)
   * @param showTransparency true to make transparent pixels, false to replace them by a background
   *     color
   */
  public void paint(Graphics g, double zoom, boolean showTransparency) {

    if (resizableImage == null) {
      resizableImage = Project.getEditorImageOrEmpty("entity_sensor_resizable.png");
    }

    Rectangle positionInMap = getPositionInMap();
    int x = (int) (positionInMap.x * zoom);
    int y = (int) (positionInMap.y * zoom);
    int w = (int) (positionInMap.width * zoom);
    int h = (int) (positionInMap.height * zoom);

    g.setColor(new Color(200, 224, 96));
    g.fillRect(x, y, w, h);

    int dx1 = (int) ((positionInMap.x + positionInMap.width / 2 - 8) * zoom);
    int dy1 = (int) ((positionInMap.y + positionInMap.height / 2 - 8) * zoom);
    int dx2 = (int) (dx1 + 16 * zoom);
    int dy2 = (int) (dy1 + 16 * zoom);

    int sx1 = 0;
    int sx2 = sx1 + 32;

    g.drawImage(resizableImage, dx1, dy1, dx2, dy2, sx1, 0, sx2, 32, null);

    drawEntityOutline(g, zoom, new Color(184, 200, 96));
  }
Beispiel #2
0
    /**
     * Constructor.
     *
     * @param title the title of the tab component
     * @param editor the editor of the tab (used to close the tab)
     */
    public TabComponent(final AbstractEditorPanel editor) {

      setLayout(new BorderLayout());
      setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
      setOpaque(false);

      // title
      title = new JLabel(editor.getTitle());
      title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
      add(title, BorderLayout.WEST);

      // close
      final JButton close = new JButton(Project.getEditorImageIconOrEmpty("icon_cross.png"));
      close.setPreferredSize(new Dimension(16, 16));
      close.setUI(new BasicButtonUI());
      close.setBorderPainted(false);
      close.setOpaque(false);
      close.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
              removeEditor(editor, true);
            }
          });
      close.addMouseListener(
          new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent me) {}

            @Override
            public void mousePressed(MouseEvent me) {}

            @Override
            public void mouseReleased(MouseEvent me) {}

            @Override
            public void mouseEntered(MouseEvent me) {

              close.setBorderPainted(true);
            }

            @Override
            public void mouseExited(MouseEvent me) {

              close.setBorderPainted(false);
            }
          });
      add(close, BorderLayout.EAST);
    }
 /**
  * Returns the id of any tileset editor that edits the specified tileset.
  *
  * @param tilesetId Id of a tileset.
  * @return Id of an editor that edits this tileset.
  */
 public static String getEditorId(String tilesetId) {
   return Project.getTilesetFile(tilesetId).getAbsolutePath();
 }