protected final void doActionPerformed(ActionEvent evt) {
    try {
      ApplicationDiagram diag =
          (ApplicationDiagram) (ApplicationContext.getFocusManager().getFocusObject());
      Point clickPosition = getDiagramLocation(evt);
      if (clickPosition == null)
        clickPosition = GraphicUtil.rectangleGetCenter(diag.getMainView().getViewRect());
      java.awt.Image image = SRSystemClipboard.getClipboardImage();
      if (image == null) return;
      DbObject diagGo = diag.getDiagramGO();
      Db db = diagGo.getDb();

      ImageIcon icon = new ImageIcon(image);
      int imageHeigth = icon.getIconHeight();
      int imageWidth = icon.getIconWidth();

      db.beginTrans(Db.WRITE_TRANS, LocaleMgr.action.getString("pasteDiagramImage"));

      DbObject imageGo = diagGo.createComponent(DbGraphic.fImageGoDiagramImage.getMetaClass());
      imageGo.set(DbGraphic.fImageGoDiagramImage, image);
      imageGo.set(
          DbGraphic.fGraphicalObjectRectangle,
          new Rectangle(
              clickPosition.x - (imageWidth / 2),
              clickPosition.y - (imageHeigth / 2),
              imageWidth,
              imageHeigth));
      db.commitTrans();
    } catch (Exception e) {
      org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
          ApplicationContext.getDefaultMainFrame(), e);
    }
  }
Пример #2
0
          /** 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
  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;
  }
Пример #5
0
  /** Process the action event from the open button */
  public void actionPerformed(ActionEvent evt) {
    if (openDialog == null) openDialog = new JFileChooser();

    int ret_val = openDialog.showOpenDialog(this);
    if (ret_val != JFileChooser.APPROVE_OPTION) return;

    File file = openDialog.getSelectedFile();

    try {
      System.out.println("Loading external file: " + file);

      FileInputStream is = new FileInputStream(file);
      BufferedInputStream stream = new BufferedInputStream(is);
      BufferedImage img = ImageIO.read(stream);

      if (img == null) {
        System.out.println("Image load barfed");
        return;
      }

      srcIcon.setImage(img);
      srcLabel.setIcon(srcIcon);

      BufferedImage map_img = textureUtils.createNormalMap(img, null);
      mapIcon.setImage(map_img);
      mapLabel.setIcon(mapIcon);
    } catch (IOException ioe) {
      System.out.println("crashed " + ioe.getMessage());
      ioe.printStackTrace();
    }
  }
Пример #6
0
  /**
   * 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();
  }
 /**
  * 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;
 }
Пример #8
0
 // 添加背景
 protected void paintComponent(Graphics g) {
   // TODO Auto-generated method stub
   super.paintComponent(g);
   ImageIcon background = new ImageIcon("pictures\\adminleft1.png");
   Image bg = background.getImage();
   g.drawImage(bg, 0, 0, frameWidth / 4, frameHeight, null);
 }
Пример #9
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();
 }
Пример #10
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);
   }
 }
Пример #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
  /** ************** 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);
  }
Пример #13
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();
   }
 }
Пример #14
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);
 }
Пример #15
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
  }
Пример #16
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();
 }
Пример #17
0
 /**
  * Gets an Image.
  *
  * @return the image
  */
 public Image getImage() {
   ImageIcon icon = getIcon();
   if (icon != null) {
     return icon.getImage();
   }
   return null;
 }
Пример #18
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());
 }
Пример #19
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();
 }
 /** 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);
 }
Пример #22
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);
   }
 }
Пример #23
0
  @Test
  public void testRedimensionnerImage() {
    ImageIcon imageBar = new ImageIcon("ChatDesk/src/ca/qc/bdeb/gr1_420_P56_BB/Images/bar.png");
    int tailleY = 20;
    int tailleX = 20;
    ImageIcon imageBarModifiee = Formatage.redimensionnerImage(imageBar, tailleX, tailleY);

    assertEquals(imageBarModifiee.getIconWidth(), tailleX);
    assertEquals(imageBarModifiee.getIconHeight(), tailleY);
  }
Пример #24
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());
 }
  /**
   * The main program for the MiddlemanFrame class
   *
   * @todo describe the command line arguments
   * @todo-javadoc Write javadocs for method parameter
   * @todo-javadoc Write javadocs for method parameter
   * @todo-javadoc Write javadocs for method parameter
   * @param middlegen Describe what the parameter does
   * @param title Describe what the parameter does
   */
  public JMiddlegenFrame(Middlegen middlegen, String title) {
    super(title);
    _middlegen = middlegen;
    setKuststoffLF();

    // make panel with label header and tabs in center.
    JLabel header = new JLabel("", JLabel.CENTER);
    JSettingsTabPane settingsTabs = new JSettingsTabPane(middlegen.getPlugins());
    JPanel headerTabs = new JPanel(new BorderLayout());

    headerTabs.add(header, BorderLayout.NORTH);
    // headerTabs.add(settingsTabs, BorderLayout.CENTER);
    JToolBar pluginToolBar = new JToolBar();
    pluginToolBar.add(settingsTabs);
    headerTabs.add(pluginToolBar, BorderLayout.CENTER);

    _databasePanel = new JDatabasePanel(settingsTabs, header);

    JScrollPane scroll = new JScrollPane(_databasePanel);
    _split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scroll, headerTabs);
    _split.setDividerLocation(0.5);
    getContentPane().add(_split, BorderLayout.CENTER);

    JToolBar toolBar = new JToolBar();
    toolBar.add(_generateAction);
    toolBar.addSeparator();
    toolBar.add(new JLabel("CTRL-Click relations to modify their cardinality"));
    toolBar.addSeparator();
    toolBar.add(new JLabel("SHIFT-Click relations to modify their directionality"));
    getContentPane().add(toolBar, BorderLayout.NORTH);

    ImageIcon icon = new ImageIcon(getClass().getResource("m.gif"));
    setIconImage(icon.getImage());

    // dispose Frame on closing, so VM will exit when Ant Task has finished
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    // I have a dodgy feeling that a Mac would try to exit the VM when the
    // window closes. Try to uncomment this line on a Mac.
    // System.setSecurityManager(new NoExitSecurityManager());

    addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent evt) {
            // Tell the halted Ant task to resume.
            synchronized (MiddlegenTask.getLock()) {
              // Update positions of tables
              _databasePanel.setPrefs();
              // Let the ant task to continue
              MiddlegenTask.getLock().notify();
            }
          }
        });
  }
Пример #26
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;
 }
Пример #27
0
 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);
   }
 }
Пример #28
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);
  }
Пример #29
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));
  }
Пример #30
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));
 }