Ejemplo n.º 1
0
 @Override
 public void mouseClicked(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     String ip = (String) as.getAttribute("ip");
     ScriptException se = (ScriptException) as.getAttribute("exception");
     Node node = net.getAtIP(ip);
     if (node == null) {
       Utility.displayError("Error", "Computer does not exist");
       return;
     }
     String errorString =
         "--ERROR--\n"
             + "Error at line number "
             + se.getLineNumber()
             + " and column number "
             + se.getColumnNumber()
             + "\n"
             + se.getMessage();
     new ScriptDialog(
             parentFrame,
             str -> {
               if (str != null) {
                 node.setScript(str);
               }
             },
             node.getScript(),
             errorString)
         .setVisible(true);
   }
 }
Ejemplo n.º 2
0
 public void mouseClicked(MouseEvent e) {
   if (e.getSource() == bottomText) {
     try {
       getAppletContext().showDocument(new URL(linkURL), "_blank");
     } catch (java.net.MalformedURLException ex) {
     }
   } else {
     maybeShowPopup(e);
   }
 }
Ejemplo n.º 3
0
 @Override
 public void mouseMoved(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     setCursor(handCursor);
   } else {
     setCursor(defaultCursor);
   }
 }
Ejemplo n.º 4
0
 /** Select or grow image when clicked. */
 public void mousePressed(MouseEvent e) {
   Dimension size = fComponent.getSize();
   if (e.getX() >= size.width - 7 && e.getY() >= size.height - 7 && getSelectionState() == 2) {
     // Click in selected grow-box:
     if (DEBUG) System.out.println("ImageView: grow!!! Size=" + fWidth + "x" + fHeight);
     Point loc = fComponent.getLocationOnScreen();
     fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight);
     fGrowProportionally = e.isShiftDown();
   } else {
     // Else select image:
     fGrowBase = null;
     JTextComponent comp = (JTextComponent) fContainer;
     int start = fElement.getStartOffset();
     int end = fElement.getEndOffset();
     int mark = comp.getCaret().getMark();
     int dot = comp.getCaret().getDot();
     if (e.isShiftDown()) {
       // extend selection if shift key down:
       if (mark <= start) comp.moveCaretPosition(end);
       else comp.moveCaretPosition(start);
     } else {
       // just select image, without shift:
       if (mark != start) comp.setCaretPosition(start);
       if (dot != end) comp.moveCaretPosition(end);
     }
   }
 }
Ejemplo n.º 5
0
  /** Resize image if initial click was in grow-box: */
  public void mouseDragged(MouseEvent e) {
    if (fGrowBase != null) {
      Point loc = fComponent.getLocationOnScreen();
      int width = Math.max(2, loc.x + e.getX() - fGrowBase.x);
      int height = Math.max(2, loc.y + e.getY() - fGrowBase.y);

      if (e.isShiftDown() && fImage != null) {
        // Make sure size is proportional to actual image size:
        float imgWidth = fImage.getWidth(this);
        float imgHeight = fImage.getHeight(this);
        if (imgWidth > 0 && imgHeight > 0) {
          float prop = imgHeight / imgWidth;
          float pwidth = height / prop;
          float pheight = width * prop;
          if (pwidth > width) width = (int) pwidth;
          else height = (int) pheight;
        }
      }

      resize(width, height);
    }
  }
Ejemplo n.º 6
0
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger()) {
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }
Ejemplo n.º 7
0
 /** Checks to see if the event was to show the popup menu */
 private void maybeShowPopup(MouseEvent e) {
   if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
     popup.show(userList, e.getX(), e.getY());
   }
 }
Ejemplo n.º 8
0
 public void mouseExited(MouseEvent e) {
   if (e.getSource() == bottomText) {
     bottomText.setCursor(Cursor.getDefaultCursor());
   }
 }
Ejemplo n.º 9
0
 public void mouseEntered(MouseEvent e) {
   if (e.getSource() == bottomText) {
     bottomText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   }
 }
Ejemplo n.º 10
0
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger() && back.size() > 1) popup.show(e.getComponent(), e.getX(), e.getY());
 }
Ejemplo n.º 11
0
 /** On double-click, open image properties dialog. */
 public void mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {}
 }