Beispiel #1
0
 public void move(int x, int y, String cmd, int PID) {
   if (cmd.equals("l")) {
     URL loc = this.getClass().getResource("\\res\\cop" + PID + "_l.png");
     ImageIcon iia = new ImageIcon(loc);
     Image image = iia.getImage();
     this.setImage(image);
   } else if (cmd.equals("r")) {
     URL loc = this.getClass().getResource("\\res\\cop" + PID + "_r.png");
     ImageIcon iia = new ImageIcon(loc);
     Image image = iia.getImage();
     this.setImage(image);
   } else if (cmd.equals("u")) {
     URL loc = this.getClass().getResource("\\res\\cop" + PID + "_u.png");
     ImageIcon iia = new ImageIcon(loc);
     Image image = iia.getImage();
     this.setImage(image);
   } else if (cmd.equals("d")) {
     URL loc = this.getClass().getResource("\\res\\cop" + PID + "_d.png");
     ImageIcon iia = new ImageIcon(loc);
     Image image = iia.getImage();
     this.setImage(image);
   }
   int nx = this.x() + x;
   int ny = this.y() + y;
   this.setX(nx);
   this.setY(ny);
 }
          /** Creates full size and thumbnail versions of the target image files. */
          @Override
          protected Void doInBackground() throws Exception {
            for (int i = 0; i < Length; i++) {
              ImageIcon icon;
              icon = createImageIcon(imagedir + imageFileNames[i], imageCaptions[i]);
              ThumbnailAction thumbAction;
              if (icon != null) {

                ImageIcon Icon = new ImageIcon(getScaledImage(icon.getImage(), 640, 480));

                ImageIcon thumbnailIcon = new ImageIcon(getScaledImage(icon.getImage(), 64, 64));

                thumbAction = new ThumbnailAction(Icon, thumbnailIcon, imageCaptions[i]);

              } else {
                // the image failed to load for some reason
                // so load a placeholder instead
                thumbAction =
                    new ThumbnailAction(placeholderIcon, placeholderIcon, imageCaptions[i]);
              }
              publish(thumbAction);
            }
            // unfortunately we must return something, and only null is valid to
            // return when the return type is void.
            return null;
          }
Beispiel #3
0
  public static void attachIcon(Window frame) {
    if (ICONS == null) {
      List<Image> loadedIcons = new ArrayList<Image>();
      ClassLoader loader = LFrame.class.getClassLoader();
      for (int size : SIZES) {
        URL url = loader.getResource(PATH + size + ".png");
        if (url != null) {
          ImageIcon icon = new ImageIcon(url);
          loadedIcons.add(icon.getImage());
          if (size == DEFAULT_SIZE) {
            DEFAULT_ICON = icon.getImage();
          }
        }
      }
      ICONS = loadedIcons;
    }

    boolean success = false;
    try {
      if (ICONS != null && !ICONS.isEmpty()) {
        Method set = frame.getClass().getMethod("setIconImages", List.class);
        set.invoke(frame, ICONS);
        success = true;
      }
    } catch (Exception e) {
    }

    if (!success && frame instanceof JFrame && DEFAULT_ICON != null) {
      ((JFrame) frame).setIconImage(DEFAULT_ICON);
    }
  }
  public Character() {
    try {
      ImageIcon iiP = new ImageIcon(resourcesPath + imageCount + ".png");
      this.image = iiP.getImage();
      image = iiP.getImage();
    } catch (Exception e) {
      System.out.println("Exception: " + e.getMessage());
    }

    int width =
        Integer.parseInt(
            RossLib.parseXML(resourcesPath + "character_data.xml", "character", "bobert", "width"));
    int height =
        Integer.parseInt(
            RossLib.parseXML(
                resourcesPath + "character_data.xml", "character", "bobert", "height"));
    name = RossLib.parseXML(dataPath, "character", "bobert", "name");
    worldObjectType = WorldObjectType.CHARACTER;
    collisionType = CollisionType.IMPASSABLE;
    horizVelocity = 0;
    int defaultX = (int) (Main.B_WINDOW_WIDTH * 0.5);
    int defaultY = 350;
    initBoxes(
        new Rectangle(
            defaultX, defaultY,
            width, height));
  }
  /*Add button to master panel*/
  private void addHistoryButton(JFrame frame, JPanel panel) {
    ImageIcon buttonImage = new ImageIcon("assets\\other\\button.png");
    ImageIcon buttonPressedImage = new ImageIcon("assets\\other\\buttonPressed.png");
    // button
    JPanel buttonHolder = new JPanel();
    this.searchButton = new JButton("MATCH HISTORY");
    this.searchButton.setPreferredSize(new Dimension(222, 50));
    this.searchButton.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 10)); // custom font
    this.searchButton.setForeground(Color.WHITE); // text color
    this.searchButton.setBackground(Color.DARK_GRAY);
    this.searchButton.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    this.searchButton.setHorizontalTextPosition(AbstractButton.CENTER);
    // search button background image
    // regular button
    Image tempImage = buttonImage.getImage();
    Image newTempImg = tempImage.getScaledInstance(222, 50, Image.SCALE_SMOOTH);
    buttonImage = new ImageIcon(newTempImg);
    // pressed button
    Image tempImage2 = buttonPressedImage.getImage();
    Image newTempImg2 = tempImage2.getScaledInstance(222, 50, Image.SCALE_SMOOTH);
    buttonPressedImage = new ImageIcon(newTempImg2);
    this.searchButton.setIcon(buttonImage);
    this.searchButton.setRolloverIcon(buttonPressedImage);

    this.searchButton.addActionListener(this);
    buttonHolder.add(this.searchButton);
    buttonHolder.setOpaque(false);
    panel.add(buttonHolder);
  }
Beispiel #6
0
  /**
   * Scale image to the given percentage. Caller chooses whether enclosing window is to grow with
   * the resize, or not.
   *
   * @param targetPercentage Desired final percentage of image's original size.
   * @param expandWindow If true then the surrounding window grows/shrinks with the
   *     enlargement/reduction
   */
  public void percentScaleImage(int targetPercentage, boolean expandWindow) {

    Image img = _fullSizeImgIcon.getImage();

    ImageIcon imgIcon = new ImageIcon(img);
    int width = imgIcon.getIconWidth();

    int newWidth = new Double(width * targetPercentage / 100f).intValue();
    imgIcon.setImage(getScaledImage(imgIcon, newWidth));

    _panel.remove(_label);
    _label = new JLabel(imgIcon);
    _panel.add(_label);

    if (expandWindow) pack();
    else validate();

    setTitle(
        _titleBarStartTxt
            + ": "
            + targetPercentage
            + "% of "
            + _fullSizeImgIcon.getImage().getWidth(null)
            + "x"
            + _fullSizeImgIcon.getImage().getHeight(null)
            + " ("
            + imgIcon.getImage().getWidth(null)
            + "x"
            + imgIcon.getImage().getHeight(null)
            + ").");
  }
Beispiel #7
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(Color.black);
   add(l);
   add(s);
   drawSpecialLines(g);
   g.setColor(Color.white);
   g.fillOval(30, 100, 75, 75);
   g.setColor(Color.blue);
   g.fillRect(getWidth() / 2, getHeight() / 2, (int) bl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 40, (int) gl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 80, (int) ll, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 120, (int) sl, 10);
   g.drawImage(bullet.getImage(), 30, getHeight() / 2 - 10, 20, 20, null);
   g.drawImage(grenade.getImage(), 30, getHeight() / 2 + 40 - 10, 20, 20, null);
   g.drawImage(laser.getImage(), 30, getHeight() / 2 + 80 - 10, 20, 20, null);
   g.drawImage(shotgun.getImage(), 30, getHeight() / 2 + 120 - 10, 20, 20, null);
   g.setColor(Color.yellow);
   if (gunTrack == 0) {
     g.drawRect(30, getHeight() / 2 - 10, 20, 20);
   } else if (gunTrack == 1) {
     g.drawRect(30, getHeight() / 2 + 40 - 10, 20, 20);
   } else if (gunTrack == 2) {
     g.drawRect(30, getHeight() / 2 + 80 - 10, 20, 20);
   } else {
     g.drawRect(30, getHeight() / 2 + 120 - 10, 20, 20);
   }
 }
Beispiel #8
0
  @Override
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setColor(new Color(0, 0, 0));

    for (int j = 0; j < 8; j++) {
      ImageIcon ii = new ImageIcon(this.getClass().getResource("/images/" + 2 + ".png"));
      g2.drawImage(ii.getImage(), j * 70, 560, this);
    }

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        ImageIcon ii =
            new ImageIcon(this.getClass().getResource("/images/" + mGame[i][j] + ".png"));
        g2.setFont(new Font("ARIAL", Font.BOLD, 60));
        if (mGame[i][j] == OK) {
          g2.drawString(" " + logic.getScore(), j * 70, i * 70);
        }
        if (mGame[i][j] == ERROR) {
          g2.drawString("-3", j * 70, i * 70);
        }
        g2.drawImage(ii.getImage(), j * 70, i * 70, this);
        g2.setFont(new Font("ARIAL", Font.BOLD, 20));
        g2.setColor(Color.DARK_GRAY);

        g2.drawString("Seus Tijolos : " + logic.getScore(), 10, 600);
        g2.drawString("Quantidade : " + QUANTIDADE_TIJOLO, 200, 600);
        g2.drawString("Tempo : " + time, 450, 600);
      }
    }
  }
 public void mouseClicked(MouseEvent e) {
   Tile t = (Tile) e.getSource();
   ImageIcon temp = (ImageIcon) t.getIcon();
   currTileImg = new ImageIcon(scaleImage(temp.getImage(), DISPLAY_SCALE));
   currTileDisplay.setIcon(new ImageIcon(scaleImage(temp.getImage(), DISPLAY_SCALE * 2)));
   currTileLoc = t.getSource();
 }
  public void getNextHero() {
    anyHero = this.heroManager.getHero();

    ImageIcon icon1 = anyHero.getIcon(0);
    Image image1 = icon1.getImage();
    Image resizedImage1 = image1.getScaledInstance(photo1.getWidth(), photo1.getHeight(), 0);
    photo1.setIcon(new ImageIcon(resizedImage1));

    ImageIcon icon2 = anyHero.getIcon(1);
    Image image2 = icon2.getImage();
    Image resizedImage2 = image2.getScaledInstance(photo2.getWidth(), photo2.getHeight(), 0);
    photo2.setIcon(new ImageIcon(resizedImage2));

    ImageIcon icon3 = anyHero.getIcon(2);
    Image image3 = icon3.getImage();
    Image resizedImage3 = image3.getScaledInstance(photo3.getWidth(), photo3.getHeight(), 0);
    photo3.setIcon(new ImageIcon(resizedImage3));
    // prosarmogh eikonwn sta label

    System.out.println(anyHero.getName());
    // yparxei boithitika gia na fainetai to onoma

    nameArea.setText("");
    // katharizei to textArea

  }
Beispiel #11
0
  public GameScreen() {
    addKeyListener(new TAdapter());
    addMouseListener(new CustomListener());
    addMouseMotionListener(new CustomListener());
    setFocusable(true);
    setBackground(Color.BLACK);
    setDoubleBuffered(true);
    player = new Sprite();
    player.setX(500);
    player.setY(250);
    player.set_speed(player_speed);
    bullet = new Vector<Bullet>();
    enemy = new Vector<Enemy>();
    v_explosion = new Vector<Explosion>();
    ImageIcon ii =
        new ImageIcon(this.getClass().getResource("Data/Sprite/background/background1.png"));
    fon = ii.getImage();
    timer = new Timer(5, this);
    timer.start();
    timerj = new java.util.Timer();
    timerj.schedule(task, 100);
    ImageIcon ii2 = new ImageIcon(this.getClass().getResource("Data/Sprite/player/explosion.png"));
    explosion = ii2.getImage();

    ImageIcon i3 = new ImageIcon(this.getClass().getResource("Data/Sprite/player/live.png"));
    live = i3.getImage();
    i3 = new ImageIcon(this.getClass().getResource("Data/Sprite/player/str.png"));
    pointer = i3.getImage();
    image_bullet = new Bullet();
    start_game();
  }
  /**
   * Sets the image to display in the frame.
   *
   * @param imageIcon the image to display in the frame
   */
  public void setImageIcon(ImageIcon imageIcon) {
    // Intercept the action to validate the user icon and not the default
    super.setImageIcon(imageIcon.getImage());
    this.isDefaultImage = false;

    this.currentImage = imageIcon.getImage();
  }
  /** Load the thumb and arrow images. */
  private void loadThumbArrowImage() {
    IconManager icons = IconManager.getInstance();

    ImageIcon img = icons.getImageIcon(IconManager.THUMB);
    thumbWidth = img.getIconWidth();
    thumbHeight = img.getIconHeight();
    thumbImage = img.getImage();
    img = icons.getImageIcon(IconManager.THUMB_DISABLED);
    disabledThumbImage = img.getImage();

    img = icons.getImageIcon(IconManager.UP_ARROW_DISABLED_10);
    arrowWidth = img.getIconWidth();
    arrowHeight = img.getIconHeight();
    minArrowHeight = arrowHeight;
    minArrowWidth = arrowWidth;
    upArrowDisabledImage = img.getImage();
    img = icons.getImageIcon(IconManager.DOWN_ARROW_DISABLED_10);
    downArrowDisabledImage = img.getImage();
    img = icons.getImageIcon(IconManager.LEFT_ARROW_DISABLED_10);
    leftArrowDisabledImage = img.getImage();
    img = icons.getImageIcon(IconManager.RIGHT_ARROW_DISABLED_10);
    rightArrowDisabledImage = img.getImage();
    img = icons.getImageIcon(IconManager.UP_ARROW_10);
    upArrowImage = img.getImage();
    img = icons.getImageIcon(IconManager.DOWN_ARROW_10);
    downArrowImage = img.getImage();
    img = icons.getImageIcon(IconManager.LEFT_ARROW_10);
    leftArrowImage = img.getImage();
    img = icons.getImageIcon(IconManager.RIGHT_ARROW_10);
    rightArrowImage = img.getImage();
  }
Beispiel #14
0
  public void actionPerformed(ActionEvent e) {
    // obtain a HardcopyWriter to do this
    Roster r = Roster.instance();
    String title = "DecoderPro Roster";
    String rosterGroup = r.getDefaultRosterGroup();
    // rosterGroup may legitimately be null
    // but getProperty returns null if the property cannot be found, so
    // we test that the property exists before attempting to get its value
    if (Beans.hasProperty(wi, RosterGroupSelector.SELECTED_ROSTER_GROUP)) {
      rosterGroup = (String) Beans.getProperty(wi, RosterGroupSelector.SELECTED_ROSTER_GROUP);
    }
    if (rosterGroup == null) {
      title = title + " All Entries";
    } else {
      title = title + " Group " + rosterGroup + " Entires";
    }
    HardcopyWriter writer = null;
    try {
      writer = new HardcopyWriter(mFrame, title, 10, .5, .5, .5, .5, isPreview);
    } catch (HardcopyWriter.PrintCanceledException ex) {
      log.debug("Print cancelled");
      return;
    }

    // add the image
    ImageIcon icon =
        new ImageIcon(FileUtil.findURL("resources/decoderpro.gif", FileUtil.Location.INSTALLED));
    // we use an ImageIcon because it's guaranteed to have been loaded when ctor is complete
    writer.write(icon.getImage(), new JLabel(icon));
    // Add a number of blank lines, so that the roster entry starts below the decoderpro logo
    int height = icon.getImage().getHeight(null);
    int blanks = (height - writer.getLineAscent()) / writer.getLineHeight();

    try {
      for (int i = 0; i < blanks; i++) {
        String s = "\n";
        writer.write(s, 0, s.length());
      }
    } catch (IOException ex) {
      log.warn("error during printing: " + ex);
    }

    // Loop through the Roster, printing as needed
    List<RosterEntry> l = r.matchingList(null, null, null, null, null, null, null); // take all
    log.debug("Roster list size: " + l.size());
    for (RosterEntry re : l) {
      if (rosterGroup != null) {
        if (re.getAttribute(Roster.getRosterGroupProperty(rosterGroup)) != null
            && re.getAttribute(Roster.getRosterGroupProperty(rosterGroup)).equals("yes")) {
          re.printEntry(writer);
        }
      } else {
        re.printEntry(writer);
      }
    }

    // and force completion of the printing
    writer.close();
  }
Beispiel #15
0
 @Override
 protected void paintComponent(Graphics g) {
   if (isEnlarged) {
     if (shrinkImage != null) g.drawImage(shrinkImage.getImage(), x, y, null);
   } else {
     if (enlargeImage != null) g.drawImage(enlargeImage.getImage(), x, y, null);
   }
 }
  /** The class constructor. */
  public Herbivore() {
    int x = RandomGenerator.nextNumber(10) + 1;

    if (x >= 6) img = IMAGE1.getImage();
    else if (x <= 5) img = IMAGE2.getImage();

    newIcon = new ImageIcon(img);
    setOpaque(false);
  }
Beispiel #17
0
 public static ImageIcon resizePic(String iconLoc, int width, int height) {
   ImageIcon resizedImage = new ImageIcon(iconLoc);
   if (resizedImage.getIconHeight() > height)
     resizedImage =
         new ImageIcon(resizedImage.getImage().getScaledInstance(-1, height, Image.SCALE_SMOOTH));
   if (resizedImage.getIconWidth() > width)
     resizedImage =
         new ImageIcon(resizedImage.getImage().getScaledInstance(width, -1, Image.SCALE_SMOOTH));
   return resizedImage;
 }
 public BufferedImage GetImage() {
   if (m_image.getImage() instanceof BufferedImage) return (BufferedImage) m_image.getImage();
   Image image = m_image.getImage();
   BufferedImage bimage =
       new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
   Graphics m_graphics = bimage.createGraphics();
   m_graphics.drawImage(image, 0, 0, image.getWidth(null), image.getHeight(null), null);
   m_image = new ImageIcon(bimage);
   return bimage;
 }
Beispiel #19
0
 protected void buildTabPane() {
   this.tabPane = new JTabbedPane();
   this.tabPane.setTabPlacement(JTabbedPane.RIGHT);
   ImageIcon icon = new ImageIcon(getClass().getResource("typing.gif"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Text", icon, new TextPanel(this));
   icon = new ImageIcon(getClass().getResource("chat.jpg"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("IRC", icon, new IRCPanel(this));
   icon = new ImageIcon(getClass().getResource("www.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Http", icon, new HttpPanel(this));
   icon = new ImageIcon(getClass().getResource("Email.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Email", icon, new EmailPanel(this));
   icon = new ImageIcon(getClass().getResource("twitter.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Twitter", icon, new TwitterPanel(this));
   icon = new ImageIcon(getClass().getResource("eye.gif"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Vision", icon, new JPanel());
   icon = new ImageIcon(getClass().getResource("brain.gif"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Bot", icon, new ContextPanel(this));
   icon = new ImageIcon(getClass().getResource("DrawingHands.jpg"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Self", icon, new SelfPanel(this));
   icon = new ImageIcon(getClass().getResource("log-icon.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Log", icon, new StatusPanel(this));
 }
Beispiel #20
0
 // method overload the constructor so you can have ImageIcon buttons, Image buttons, or String
 // buttons (like JButton);
 public BillyButton(ImageIcon img, String filename) {
   // set up images with the black one for when its selected
   this.img = img;
   enabled = true;
   image = img.getImage();
   this.filename = filename;
   BWimg = new ImageIcon("Real Pok Pics\\" + filename + "Chosen.gif");
   BWimage = BWimg.getImage();
   mode = "ImageIcon";
   visible = true;
 }
Beispiel #21
0
 // ImageIcon 객체를 BufferedImage 로 변환한다. load 시 사용
 private BufferedImage toBufferedImage(ImageIcon im) { // 추가된 메소드
   BufferedImage bi =
       new BufferedImage(
           im.getImage().getWidth(null),
           im.getImage().getHeight(null),
           BufferedImage.TYPE_4BYTE_ABGR);
   Graphics bg = bi.getGraphics();
   bg.drawImage(im.getImage(), 0, 0, null);
   bg.dispose();
   return bi;
 }
 @Override
 public void stateChanged(Chat chat, ChatState state) {
   if (ChatState.composing.equals(state)) {
     changeSysTrayIcon();
   } else {
     if (!newMessage) trayIcon.setImage(availableIcon.getImage());
     else {
       trayIcon.setImage(newMessageIcon.getImage());
     }
   }
 }
 private void lMuestraImagenSeleccionar(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_lMuestraImagenSeleccionar
   if (this.dSelector.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
     ImageIcon aux = new ImageIcon(this.dSelector.getSelectedFile().getPath());
     imagen = new ImageIcon();
     imagen.setImage(new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB));
     imagen.getImage().getGraphics().drawImage(aux.getImage(), 0, 0, 200, 200, null);
     this.lMuestraImagen.setText("");
     this.lMuestraImagen.setIcon(imagen);
   }
 } // GEN-LAST:event_lMuestraImagenSeleccionar
 public Enemy() {
   ImageIcon ii = new ImageIcon("/home/austin/workspace/Roguelike/src/resources/estill.png");
   ImageIcon iib = new ImageIcon("/home/austin/workspace/Roguelike/src/resources/eattack.png");
   still = ii.getImage();
   attack = iib.getImage();
   image = still;
   x = 6;
   y = 6;
   health = 1000;
   attacking = true;
 }
  public Image getImage() {

    img = i13.getImage();

    if (right == true) {
      releaseLeft = false;
      img = arnRunning_R[nCounter];
      nCounter++;

      if (nCounter == 6) {
        nCounter = 0;
      }

      if (right == false) {
        nCounter = 0;
      }
    }
    if (left == true) {
      releaseRight = false;
      img = arnRunning_L[nCounter];
      nCounter++;
      if (nCounter == 6) {
        nCounter = 0;
      }
      if (left == false) {
        nCounter = 0;
      }
    }
    if (isJumping == true) {
      // for(int i = 0; i < 5; i++){
      img = arnjumping_R[nCounter];
      // nCounter++;
      if (isJumping == false) {
        nCounter = 0;
      }

    } else if (releaseLeft == true) {
      img = i14.getImage();
    } // else if (releaseRight == true) {
    // img = i13.getImage();
    // }

    /*else {
    img = arnStanding_R[nCounter];
    nCounter++;

    if (nCounter == 8) {
    nCounter = 0;
    }
    }*/

    return img;
  }
Beispiel #26
0
  static {
    ImageIcon greenIcon = new ImageIcon(Tray.class.getResource("/green.png"));
    ImageIcon yellowIcon = new ImageIcon(Tray.class.getResource("/yellow.png"));
    ImageIcon redIcon = new ImageIcon(Tray.class.getResource("/red.png"));

    statusMap.put(JENKINS_STATUS_FAILURE, USB_STATUS_FAILURE);
    statusMap.put(JENKINS_STATUS_PENDING, USB_STATUS_PENDING);
    statusMap.put(JENKINS_STATUS_SUCCESS, USB_STATUS_SUCCESS);

    iconMap.put(JENKINS_STATUS_FAILURE, redIcon.getImage());
    iconMap.put(JENKINS_STATUS_PENDING, yellowIcon.getImage());
    iconMap.put(JENKINS_STATUS_SUCCESS, greenIcon.getImage());
  }
Beispiel #27
0
 @Override
 public void addRow(Author a) {
   Band b = (Band) a;
   Object data[] = {null, b.getName()};
   if (b.getPrimaryKey() < 0) {
     ImageIcon tmp = new ImageIcon(GlobalPaths.CROSS_SIGN.toString());
     data[0] = new ImageIcon(tmp.getImage().getScaledInstance(10, 10, Image.SCALE_FAST));
   } else {
     ImageIcon tmp = new ImageIcon(GlobalPaths.OK_SIGN.toString());
     data[0] = new ImageIcon(tmp.getImage().getScaledInstance(10, 10, Image.SCALE_FAST));
   }
   this.tableModel.addRow(data);
   this.rowToAuthor.put(this.rowToAuthor.size(), a);
 }
 public void paintComponent(Graphics g) {
   int x = 0, y = 0;
   java.net.URL imgURL = getClass().getResource("/resources/CarcassonneGameBoard.png");
   ImageIcon icon = new ImageIcon(imgURL);
   g.drawImage(icon.getImage(), 0, 0, getSize().width, getSize().height, this);
   while (true) {
     g.drawImage(icon.getImage(), x, y, this);
     if (x > getSize().width && y > getSize().height) break;
     if (x > getSize().width) {
       x = 0;
       y += icon.getIconHeight();
     } else x += icon.getIconWidth();
   }
 }
Beispiel #29
0
 private JPanel createTopPanel() {
   JPanel panel =
       new JPanel() {
         @Override
         protected void paintComponent(Graphics g) {
           setOpaque(false);
           g.drawImage(
               BANNER.getImage(), (getWidth() - BANNER.getImage().getWidth(null)) / 2, 0, null);
           super.paintComponent(g);
         }
       };
   panel.setPreferredSize(
       new Dimension(BANNER.getImage().getWidth(null), BANNER.getImage().getHeight(null)));
   return panel;
 }
  /**
   * Returns an object which represents the data to be transferred. The class of the object returned
   * is defined by the representation class of the flavor.
   *
   * @param flavor the requested flavor for the data
   * @throws IOException if the data is no longer available in the requested flavor.
   * @throws UnsupportedFlavorException if the requested data flavor is not supported.
   * @see DataFlavor#getRepresentationClass
   */
  public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (isRicherFlavor(flavor)) {
      return getRicherData(flavor);
    } else if (isImageFlavor(flavor)) {
      if (image != null && image.getImage() instanceof RenderedImage) {
        if (flavor.equals(DataFlavor.imageFlavor)) {
          return image.getImage();
        } else {
          ByteArrayOutputStream stream = new ByteArrayOutputStream();
          ImageIO.write((RenderedImage) image.getImage(), "bmp", stream);

          return new ByteArrayInputStream(stream.toByteArray());
        }
      }
    } else if (isHtmlFlavor(flavor)) {
      String data = getHtmlData();
      data = (data == null) ? "" : data;

      if (String.class.equals(flavor.getRepresentationClass())) {
        return data;
      } else if (Reader.class.equals(flavor.getRepresentationClass())) {
        return new StringReader(data);
      } else if (InputStream.class.equals(flavor.getRepresentationClass())) {
        return new ByteArrayInputStream(data.getBytes());
      }
      // fall through to unsupported
    } else if (isPlainFlavor(flavor)) {
      String data = getPlainData();
      data = (data == null) ? "" : data;

      if (String.class.equals(flavor.getRepresentationClass())) {
        return data;
      } else if (Reader.class.equals(flavor.getRepresentationClass())) {
        return new StringReader(data);
      } else if (InputStream.class.equals(flavor.getRepresentationClass())) {
        return new ByteArrayInputStream(data.getBytes());
      }
      // fall through to unsupported

    } else if (isStringFlavor(flavor)) {
      String data = getPlainData();
      data = (data == null) ? "" : data;

      return data;
    }

    throw new UnsupportedFlavorException(flavor);
  }