示例#1
0
  /**
   * Adds the componentType buttons to the Panel of Main Window.
   *
   * @param pkg_name whose componentType buttons will be added
   * @param a needed for the addition of the ActionListener of respective buttons and calling method
   *     of Pad_Draw
   */
  public void add_componentType_buttons(package_cls pkg_name, final counts a) {
    int i;
    JLabel pkg_hdng = new JLabel(pkg_name.getName());
    panel.add(pkg_hdng);
    for (i = 0; i < pkg_name.getComponentType_list().size(); i++) {
      final componentType cmp_Types = pkg_name.getComponentType_list().get(i);
      int btnHeight, btnWidth;
      double scale = 0.5;
      btnWidth = (int) (scale * (double) cmp_Types.getWidth());
      btnHeight = (int) (scale * (double) cmp_Types.getHeight());
      ImageIcon myIcon = new ImageIcon(cmp_Types.getType_Img());

      BufferedImage bi = new BufferedImage(btnWidth, btnHeight, BufferedImage.TYPE_INT_ARGB);
      Graphics2D g = bi.createGraphics();
      g.scale(scale, scale);
      myIcon.paintIcon(null, g, 0, 0);
      g.dispose();

      JButton strctButton = new JButton(new ImageIcon(bi));
      strctButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              drawPad.add_componentType(cmp_Types, a);
              taskbar.setText("Click to add a component");
            }
          });
      panel.add(strctButton);
    }
    panel.validate(); // Updates the Panel
  }
          /** 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;
          }
示例#3
0
 public RoundedShadowBorder() {
   insets = new Insets(0, 0, 0, 0);
   insets.bottom = bottomLeftCorner.getIconHeight() + backgroundThickness;
   insets.top = topLeftCorner.getIconHeight() + backgroundThickness;
   insets.left = topLeftCorner.getIconHeight() + backgroundThickness;
   insets.right = topRightCorner.getIconHeight() + backgroundThickness;
 }
示例#4
0
 public PlayGamePanel(JFrame frame, BoardConfiguration bc) {
   this.bc = bc;
   this.frame = frame;
   ImageIcon icon = new ImageIcon("ent.jpg");
   this.image = icon.getImage();
   this.one = new TransparentButton("1 Player");
   this.two = new TransparentButton("2 Players");
   this.three = new TransparentButton("3 Players");
   this.four = new TransparentButton("4 Players");
   this.setSize(frame.getSize());
   this.setLocation(0, 0);
   this.setLayout(null);
   one.setBounds(450, 140, 200, 40);
   two.setBounds(450, 200, 200, 40);
   three.setBounds(450, 260, 200, 40);
   four.setBounds(450, 320, 200, 40);
   this.add(one);
   this.add(two);
   this.add(three);
   this.add(four);
   this.back = new TransparentButton("Back");
   back.setBounds(450, 380, 200, 40);
   this.add(back);
   this.one.setFont(new Font("calibri", Font.ITALIC, 30));
   this.two.setFont(new Font("calibri", Font.ITALIC, 30));
   this.three.setFont(new Font("calibri", Font.ITALIC, 30));
   this.four.setFont(new Font("calibri", Font.ITALIC, 30));
   this.back.setFont(new Font("calibri", Font.ITALIC, 30));
   this.one.addMouseListener(this);
   this.two.addMouseListener(this);
   this.three.addMouseListener(this);
   this.four.addMouseListener(this);
   this.back.addMouseListener(this);
   this.back.setForeground(Color.red);
 }
  /**
   * 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();
  }
示例#6
0
 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();
 }
示例#7
0
 /**
  * Gets an Image.
  *
  * @return the image
  */
 public Image getImage() {
   ImageIcon icon = getIcon();
   if (icon != null) {
     return icon.getImage();
   }
   return null;
 }
示例#8
0
 public void init() {
   vlog.debug("init called");
   setBackground(Color.white);
   ClassLoader cl = this.getClass().getClassLoader();
   ImageIcon icon = new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.png"));
   logo = icon.getImage();
 }
示例#9
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);
   }
 }
示例#10
0
  /** ************** Display result of processed Image *********** */
  void imageResultDisplay(int width, int height, int pix[]) {

    img_temp = createImage(new MemoryImageSource(width, height, pix, 0, width));
    ImageIcon imgIcon = new ImageIcon();
    imgIcon.setImage(img_temp);
    lbl_res.setIcon(imgIcon);
  }
示例#11
0
  /** ****************** Display Gray Scale version of image opened *************** */
  void grayImageDisplay(int width, int height, int pix[]) {

    img_temp = createImage(new MemoryImageSource(width, height, pix, 0, width));
    ImageIcon imgI = new ImageIcon();
    imgI.setImage(img_temp);
    lbl_gray.setIcon(imgI);
  }
示例#12
0
 private void updateGraph() {
   if (sourceIdentifier != null
       && selectedGraph >= 0
       && selectedGraph < graphImageFactories.length) {
     GraphImageProducer graphImageFactory = graphImageFactories[selectedGraph];
     imageToggle[imageIndex] =
         graphImageFactory.createGraphImage(
             Util.getTime(),
             sourceIdentifier,
             imageToggle[imageIndex],
             showMaxCheckBox.isSelected());
     if (imageToggle[imageIndex] != null) {
       ImageIcon graphImageIcon = new ImageIcon();
       graphImageIcon.setImage(imageToggle[imageIndex]);
       graphLabel.setIcon(graphImageIcon);
       graphLabel.setText("");
     } else {
       graphLabel.setIcon(null);
       graphLabel.setText("Couldn't create graph image!");
     }
     if (imageIndex == 0) {
       imageIndex = 1;
     } else {
       imageIndex = 0;
     }
     graphLabel.repaint();
   }
 }
 /**
  * Gets the IconBox for the specified image IRI.
  *
  * @param iri The IRI pointing to the image.
  * @return The icon box containing the image.
  * @throws MalformedURLException
  */
 private IconBox getImageBox(IRI iri) throws MalformedURLException {
   ImageIcon imageIcon = new ImageIcon(iri.toURI().toURL());
   imageIcon.getImageLoadStatus();
   IconBox iconBox = new IconBox(imageIcon, new HTTPLink(iri.toURI()));
   iconBox.setMaxHeight(50);
   return iconBox;
 }
示例#14
0
  private BufferedImage generateFrame(GifFrame frame) {
    int width = frame.getColumns() * CELL_WIDTH;
    BufferedImage img =
        new BufferedImage(width, frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT, IMAGE_TYPE_GIF);
    Graphics graphics = img.getGraphics();
    for (int row = 0; row < frame.getRows(); row++) {
      for (int col = 0; col < frame.getColumns(); col++) {
        ImageIcon icon =
            new ImageIcon(
                "site/images/" + frame.getBoard().get(row, col).getImageFilename() + ".png");
        graphics.drawImage(icon.getImage(), col * CELL_WIDTH, row * CELL_HEIGHT, null);
      }
    }

    for (BoxOverlay overlay : frame.getOverlays()) {
      graphics.setColor(overlay.getColor());
      Rectangle rect = overlay.getRectangle();
      int rect_x = rect.getLeft() * CELL_WIDTH - OVERLAY_PADDING;
      int rect_y = rect.getTop() * CELL_HEIGHT - OVERLAY_PADDING;
      int rect_width = (rect.getRight() - rect.getLeft() + 1) * CELL_WIDTH + 2 * OVERLAY_PADDING;
      int rect_height = (rect.getBottom() - rect.getTop() + 1) * CELL_HEIGHT + 2 * OVERLAY_PADDING;
      graphics.drawRect(rect_x, rect_y, rect_width, rect_height);
      graphics.drawRect(rect_x - 1, rect_y - 1, rect_width + 2, rect_height + 2);
    }

    graphics.setColor(FONT_COLOR);
    graphics.setFont(FONT);
    FontMetrics fm = graphics.getFontMetrics();
    graphics.drawString(
        frame.getText(),
        width / 2 - fm.stringWidth(frame.getText()) / 2,
        frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT / 2 + fm.getHeight() / 2);

    return img;
  }
示例#15
0
 public Player(double x) {
   hp = 100;
   pX = x;
   playerTex = new ImageIcon("TEXTURE/stickman.png");
   pY = Constants.GROUND - playerTex.getIconHeight();
   pRect =
       new Rectangle2D.Double(x + playerTex.getIconWidth() / 2, pY, 1, playerTex.getIconHeight());
 }
示例#16
0
 public Board() {
   p = new Player();
   addKeyListener(new AL());
   setFocusable(true);
   ImageIcon i = new ImageIcon("C:/background.png");
   img = i.getImage();
   time = new Timer(1, this);
   time.start();
 }
示例#17
0
 /** {@inheritDoc} */
 @Override
 public void paintIcon(
     final Component c, final Graphics2D g2d, final int x, final int y, final int w, final int h) {
   if (step > -1) {
     final ImageIcon icon = enabled ? CHECK_STATES.get(step) : DISABLED_CHECK_STATES.get(step);
     g2d.drawImage(
         icon.getImage(), x + w / 2 - getIconWidth() / 2, y + h / 2 - getIconHeight() / 2, null);
   }
 }
 /** Stop animating this instance of <code>AbstractIconAnimator</code>. */
 public void stop() {
   icon.setImageObserver(null);
   icon.getImage().flush();
   Map map = (Map) contexts.get(context);
   if (map != null) {
     map.remove(key);
     if (map.size() == 0) contexts.remove(context);
   }
 }
 @Override
 public void paintComponent(Graphics g) {
   Dimension tam = getSize();
   ImageIcon ImagenFondo =
       new ImageIcon(new ImageIcon(getClass().getResource("/IMAGES/back_3.jpg")).getImage());
   g.drawImage(ImagenFondo.getImage(), 0, 0, tam.width, tam.height, null);
   setOpaque(false);
   super.paintComponent(g);
 }
示例#20
0
 /** Loads the image. */
 public static void loadImage() {
   if (fileImage != null) return; // already loaded this
   AppLib.printDebug("Loading introduction image");
   ImageIcon fi = AppLib.loadClassImage("images/title.png");
   // wait for it...
   while (fi.getImageLoadStatus() == MediaTracker.LOADING) AppLib.sleep(20L);
   // load me!
   fileImage = fi.getImage();
   screenImage = screenShot(AppLib.winInfo.getScreenSize());
 }
示例#21
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;
 }
 public void squish(Graphics g, ImageIcon icon, int x, int y, double scale) {
   if (isVisible()) {
     g.drawImage(
         icon.getImage(),
         x,
         y,
         (int) (icon.getIconWidth() * scale),
         (int) (icon.getIconHeight() * scale),
         this);
   }
 }
示例#23
0
  public Abschluss(String wahl, Sudoku s, Sudoku2 s2) {
    super("Sudoku-Abschluss");
    this.setSize(270, 135);
    this.setLocation(250, 300);
    this.setLayout(null);
    this.setAlwaysOnTop(true);
    this.setResizable(false);
    this.setUndecorated(true);
    if (s == null) this.setLocationRelativeTo(s2);
    else this.setLocationRelativeTo(s);

    su = s;
    su2 = s2;
    w = wahl;

    ImageIcon icon = new ImageIcon("files/minigames/Sudoku/beispiel2.jpg");
    icon.setImage(icon.getImage().getScaledInstance(290, 135, Image.SCALE_DEFAULT));

    lab = new JLabel(icon);
    lab.setSize(270, 135);
    lab.setLocation(0, 0);
    this.add(lab);

    text = new JLabel();
    text.setSize(250, 20);
    text.setLocation(10, 10);
    text.setForeground(Color.white);
    text.setHorizontalAlignment(0);
    lab.add(text);

    text2 = new JLabel();
    text2.setSize(270, 20);
    text2.setLocation(10, 30);
    text2.setForeground(Color.white);
    lab.add(text2);

    ok = new JButton("OK");
    ok.setSize(90, 30);
    ok.setLocation(80, 50);
    ok.setBorderPainted(false);
    ok.setBackground(Color.lightGray);
    ok.setForeground(Color.lightGray);
    ok.setOpaque(false);
    ok.setFont(new Font("Arial Black", 4, 20));
    ok.setContentAreaFilled(false);
    ok.setFocusPainted(false);
    ok.addActionListener(this);
    ok.addMouseListener(this);
    lab.add(ok);

    textWahl(wahl);

    this.setVisible(true);
  }
示例#24
0
  public void battleEnd() {
    scene = OVERWORLD;
    ImageIcon bg = new ImageIcon("OverworldBG.jpg");
    background = bg.getImage();
    player.battleEnd();
    totalExperience = 0;
    nextWindow = false;
    battleWon = false;

    enemies.add(new Stalker(175, 200));
  }
示例#25
0
 private static ImageIcon makeRolloverIcon(ImageIcon srcIcon) {
   RescaleOp op =
       new RescaleOp(new float[] {1.2f, 1.2f, 1.2f, 1f}, new float[] {0f, 0f, 0f, 0f}, null);
   BufferedImage img =
       new BufferedImage(
           srcIcon.getIconWidth(), srcIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
   Graphics g = img.getGraphics();
   // g.drawImage(srcIcon.getImage(), 0, 0, null);
   srcIcon.paintIcon(null, g, 0, 0);
   g.dispose();
   return new ImageIcon(op.filter(img, null));
 }
 public void loadImage(File f) {
   if (f == null) {
     thumbnail = null;
   } else {
     ImageIcon tmpIcon = new ImageIcon(f.getPath());
     if (tmpIcon.getIconWidth() > 90) {
       thumbnail =
           new ImageIcon(tmpIcon.getImage().getScaledInstance(90, -1, Image.SCALE_DEFAULT));
     } else {
       thumbnail = tmpIcon;
     }
   }
 }
示例#27
0
  public void resize() {

    height = (height == 0) ? 1 : height;

    ratio = (double) image.getIconWidth() / image.getIconHeight();

    Image img = image.getImage();
    width = width - 10;
    // 4 = Image.SCALE_SMOOTH
    Image newimg = img.getScaledInstance(width, (int) (width / ratio), 4);

    label1.setIcon(new ImageIcon(newimg));
  }
示例#28
0
 public static ImageIcon AboutImage() {
   ImageIcon image = null;
   String imagename = Settings().getAboutImage();
   if ((imagename != null) && "".compareTo(imagename) != 0) {
     image = new ImageIcon();
     try {
       image.setImage(ImageIO.read(Settings().getResourceAsStream(imagename)));
     } catch (Exception e) {
       Logger().warning("About image not found " + imagename + ": " + e.getMessage());
     }
   }
   return image;
 }
 private static ImageIcon scale(ImageIcon src) {
   // System.out.println(scaleFactor);
   if (scaleFactor > 1) {
     int w = (int) (scaleFactor * src.getIconWidth());
     int h = (int) (scaleFactor * src.getIconHeight());
     int type = BufferedImage.TYPE_INT_ARGB;
     BufferedImage dst = new BufferedImage(w, h, type);
     Graphics2D g2 = dst.createGraphics();
     g2.drawImage(src.getImage(), 0, 0, w, h, null);
     g2.dispose();
     return new ImageIcon(dst);
   } else return src;
 }
  private void addMenuToTray() {
    HashMap categories = new HashMap();

    // create menu list
    Iterator plugins = PluginManager.getInstance().getAvailablePlugins();
    plugins = PluginComparator.sortPlugins(plugins);

    while (plugins.hasNext()) {
      Plugin p = (Plugin) plugins.next();

      JMenu category = (JMenu) categories.get(p.getCategory());
      if (category == null) {
        category = new JMenu(p.getCategory());
        categories.put(p.getCategory(), category);

        // copy menu to real one
        if (!p.getCategory().equals("Invisible")) this.trayIcon.add(category);
      }

      ImageIcon icon = new ImageIcon();
      try {
        icon = new ImageIcon(new URL(p.getDirectory() + p.getIcon()));
        icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH));
      } catch (Exception e) {
        // error at icon loading
      }

      JMenuItem menu = new JMenuItem(p.getTitle(), icon);
      menu.setName(p.getName());
      menu.setToolTipText(p.getToolTip());
      menu.addActionListener(this);
      category.add(menu);
    }

    this.trayIcon.addSeparator();

    // windows
    this.trayIcon.add(new WindowMenu(this));

    // open main interface
    JMenuItem menu = new JMenuItem(tr("open"));
    menu.setName("org.lucane.applications.maininterface");
    menu.addActionListener(this);
    this.trayIcon.add(menu);

    // exit
    menu = new JMenuItem(tr("exit"));
    menu.setName("exit");
    menu.addActionListener(this);
    this.trayIcon.add(menu);
  }