public void run(TaskMonitor monitor, PlugInContext context) throws Exception {
   // -- get the LM because when the Histogram will be shown, the app. focus
   //   will change and context.addLayer will not work (null pointer exc.)
   // [mmichaud 2012-04-09] to completely resolve this problem, I added the
   // new JInternalFrame is added after the addLayer method has been called
   this.currentLM = context.getLayerManager();
   monitor.allowCancellationRequests();
   if (this.selAttribute == null) {
     context.getWorkbenchFrame().warnUser(I18N.get(sNoAttributeChoosen));
     return;
   }
   javax.swing.JInternalFrame internalFrame = context.getWorkbenchFrame().getActiveInternalFrame();
   FeatureDataset result = classifyAndCreatePlot(monitor, context);
   context.getWorkbenchFrame().activateFrame(internalFrame);
   if (result == null) {
     context.getWorkbenchFrame().warnUser(I18N.get(sNotEnoughValuesWarning));
   } else if (result.size() > 0) {
     String name = this.selAttribute + "_" + this.selClassifier;
     this.currentLM.addLayer(StandardCategoryNames.WORKING, name, result);
     JInternalFrame frame = new JInternalFrame(this.sHistogram);
     frame.setLayout(new BorderLayout());
     frame.add(plot, BorderLayout.CENTER);
     frame.setClosable(true);
     frame.setResizable(true);
     frame.setMaximizable(true);
     frame.setSize(450, 450);
     context.getWorkbenchFrame().addInternalFrame(frame);
     plot = null;
   } else {
     context.getWorkbenchFrame().warnUser(sWarning);
   }
 }
Exemplo n.º 2
0
 /**
  * Ajusta el tamaño de la ventana al envelope pasado como parámetro
  *
  * @param ctx
  * @param newWrapperEnvelope
  * @param viewport
  */
 public static void resizeViewToEnvelope(
     PlugInContext ctx, Envelope newWrapperEnvelope, IViewport viewport) {
   // ajustamos las proporciones de la ventana a las de la feature
   JInternalFrame activeInternalFrame = ctx.getActiveInternalFrame();
   Dimension dimView = ((Dimension) ctx.getLayerViewPanel()).getSize();
   Double widthView = dimView.getWidth();
   Double heightView = dimView.getHeight();
   int widthDiff = (int) (activeInternalFrame.getWidth() - widthView);
   int heightDiff = (int) (activeInternalFrame.getHeight() - heightView);
   Integer newWidth =
       (int)
           ((newWrapperEnvelope.getWidth() / viewport.getEnvelopeInModelCoordinates().getWidth())
               * widthView);
   Integer newHeight =
       (int)
           ((newWrapperEnvelope.getHeight() / viewport.getEnvelopeInModelCoordinates().getHeight())
               * heightView);
   Dimension newDimensionView = new Dimension(newWidth + widthDiff, newHeight + heightDiff);
   activeInternalFrame.setSize(newDimensionView);
   // zoom al envelope actual
   try {
     viewport.zoom(newWrapperEnvelope);
   } catch (NoninvertibleTransformException e) {
     log.warn("No se ha podido alcanzar el zoom " + newWrapperEnvelope);
   }
 }
Exemplo n.º 3
0
  public Component add(JInternalFrame frame) {
    JInternalFrame[] array = getAllFrames();
    Point p;
    int w;
    int h;

    Component retval = super.add(frame);
    checkDesktopSize();
    if (array.length > 0) {
      p = array[0].getLocation();
      p.x = p.x + FRAME_OFFSET;
      p.y = p.y + FRAME_OFFSET;
    } else {
      p = new Point(0, 0);
    }
    frame.setLocation(p.x, p.y);
    if (frame.isResizable()) {
      w = getWidth() - (getWidth() / 3);
      h = getHeight() - (getHeight() / 3);
      if (w < frame.getMinimumSize().getWidth()) w = (int) frame.getMinimumSize().getWidth();
      if (h < frame.getMinimumSize().getHeight()) h = (int) frame.getMinimumSize().getHeight();
      frame.setSize(w, h);
    }
    moveToFront(frame);
    frame.setVisible(true);
    try {
      frame.setSelected(true);
    } catch (PropertyVetoException e) {
      frame.toBack();
    }
    return retval;
  }
Exemplo n.º 4
0
  private JInternalFrame _startJFXImpuestosCRUD() {
    frame = new JInternalFrame("Administrador de impuestos");
    final JFXPanel fxPanel = new JFXPanel();

    frame.setClosable(true);
    frame.add(fxPanel);
    frame.setVisible(true);

    Herramientas.panelCatalogo(frame);
    Principal.getEscritorio().getPanelEscritorio().add(frame);
    frame.setSize(706, 518);
    frame.setPreferredSize(new Dimension(706, 518));
    frame.setResizable(true);
    frame.setVisible(true);
    Herramientas.centrarVentana(frame);
    Herramientas.iconificable(frame);
    frame.toFront();

    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            Scene scene = null;
            try {
              scene = initImpuestosCRUD();
              scene.setFill(null);
              fxPanel.setScene(scene);
            } catch (IOException e) {

            }
          }
        });

    return frame;
  }
 private void agregarAPanel(JInternalFrame internal, int ancho, int largo) {
   if (!this.desktopPane.isAncestorOf(internal)) {
     this.desktopPane.add(internal);
     internal.setSize(ancho, largo);
     internal.setVisible(true);
     Dimension desktopSize = desktopPane.getSize();
     Dimension jInternalFrameSize = internal.getSize();
     internal.setLocation(
         (desktopSize.width - jInternalFrameSize.width) / 2,
         (desktopSize.height - jInternalFrameSize.height) / 2);
   }
 }
 /**
  * Creates a new {@code JInternalFrame} with a size of 200 x 100. The title of the created
  * internal frame includes the value of a counter that is automatically increased every time a new
  * internal frame is created. This method is {@code not} executed in the event dispatch thread
  * (EDT.)
  *
  * @return the created frame.
  */
 @RunsInCurrentThread
 protected static JInternalFrame createInternalFrame() {
   // TODO: should be create and add
   JInternalFrame internalFrame =
       new JInternalFrame(concat("Internal Frame ", ++internalFrameCounter));
   internalFrame.setIconifiable(true);
   internalFrame.setMaximizable(true);
   internalFrame.setResizable(true);
   internalFrame.setSize(new Dimension(200, 100));
   internalFrame.setVisible(true);
   return internalFrame;
 }
Exemplo n.º 7
0
 /**
  * Creates a new JInternalFrame based on the contents of an existing JFrame
  *
  * @param f the JFrame that will be used to create the JInternalFrame
  * @param desktop the JDesktopPane that will receive the JInternalFrame, if null it only retunrs
  *     the internal frame
  * @return a new JInternalFrame
  */
 public JInternalFrame transformToInternalFrame(JFrame f, JDesktopPane desktop) {
   JInternalFrame jif = new JInternalFrame(f.getTitle(), true, true, true, true);
   if (f.getIconImage() != null) jif.setFrameIcon(new ImageIcon(f.getIconImage()));
   if (desktop != null) desktop.add(jif);
   jif.setSize(f.getSize());
   jif.setContentPane(f.getContentPane());
   if (desktop != null) SwingUtilities.convertPointFromScreen(f.getLocation(), desktop);
   jif.setLocation(new Point(0, 0));
   jif.setBounds(f.getBounds());
   f.dispose();
   jif.setVisible(true);
   return (jif);
 }
Exemplo n.º 8
0
 /**
  * Resets the triangle graphic to the fixed default location
  *
  * @author susiefu
  */
 protected void resetTriangleToDefault() {
   int tribase =
       (Math.round((Math.min(editFrame.getSize().width, editFrame.getSize().height))) / 10 > 15)
           ? Math.round((Math.min(editFrame.getSize().width, editFrame.getSize().height))) / 10
           : 15; // How wide
   // the base
   // of the
   // triangle
   // is
   triangleFrame.setSize(tribase, TRIANGLE_DEFAULT_HEIGHT);
   ((Triangle) triangleFrame.getContentPane())
       .setGeometry("SE", 0, tribase, TRIANGLE_DEFAULT_HEIGHT, tribase);
 }
Exemplo n.º 9
0
  public JInternalFrame employeeFrame() {
    JInternalFrame f = new JInternalFrame();

    f =
        new JInternalFrame(
            "Employee Database",
            false, // Resizable
            true, // Closable
            true, // Maximizable
            true); // Iconifiable
    f.setLayout(new BorderLayout());

    JScrollPane sp = new JScrollPane(employeeTable());
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sp.setBorder(BorderFactory.createTitledBorder("Employees"));

    f.add(buttonPanel(false), BorderLayout.NORTH);
    f.add(sp);

    //		f.setLocation(loc);
    f.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
    f.setFrameIcon(images.loadImage("Images/menubar/database_icon.png"));
    f.addInternalFrameListener(this);

    if (osp.isLowResolution()) f.setSize(550, 282);
    else if (osp.isMidResolution()) f.setSize(550, 282);
    else f.setSize(850, 500); // Width, Height
    f.setVisible(true);

    try {
      f.setSelected(true);
    } catch (PropertyVetoException e1) {
      e1.printStackTrace();
    }

    return f;
  }
Exemplo n.º 10
0
  public MapEditor(LocalSettings localSettings) throws HeadlessException {
    setTitle(TITLE);
    setSize(WIDTH, HEIGHT);

    this.localSettings = localSettings;

    mainpane = new JDesktopPane();
    mainpane.setSize(WIDTH, HEIGHT);
    mainpane.setBackground(Color.GRAY);
    setContentPane(mainpane);

    LwjglApplicationConfiguration configuration = new LwjglApplicationConfiguration();
    configuration.width = WIDTH;
    configuration.height = HEIGHT;

    levelHolder = new LevelHolder();
    final LwjglCanvas lwjglCanvas = new LwjglCanvas(levelHolder, configuration);
    canvas = lwjglCanvas;
    levelHolderFrame = new JInternalFrame("EnJine2D Map", false, false, false, true);
    levelHolderFrame.setSize(WIDTH, HEIGHT);
    levelHolderFrame.setVisible(true);

    palette = new Palette("Palette", true, false, true, true);
    palette.setVisible(true);
    palette.setLevelHolder(levelHolder);
    levelHolder.setPalette(palette);

    getContentPane().add(palette);
    getContentPane().add(levelHolderFrame);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            levelHolderFrame.getContentPane().add(lwjglCanvas.getCanvas());
            setVisible(true);
          }
        });

    loadSettings();

    levelHolderFrame.addComponentListener(this);
    palette.addComponentListener(this);

    addWindowListener(this);
  }
 /**
  * Open the internal frame for the given {@link BuildOutput} (or bring it to the front, if it is
  * already open)
  *
  * @param buildOutput The {@link BuildOutput}
  */
 private void openBuildOutputFrame(BuildOutput buildOutput) {
   JInternalFrame buildOutputFrame = openedBuildOutputFrames.get(buildOutput);
   if (buildOutputFrame != null) {
     buildOutputFrame.toFront();
     return;
   }
   buildOutputFrame = new JInternalFrame(buildOutput.getProjectName(), true, true, true, true);
   openedBuildOutputFrames.put(buildOutput, buildOutputFrame);
   buildOutputFrame.addInternalFrameListener(
       new InternalFrameAdapter() {
         @Override
         public void internalFrameClosed(InternalFrameEvent e) {
           openedBuildOutputFrames.remove(buildOutput);
         }
       });
   buildOutputFrame.getContentPane().add(new BuildOutputPanel(buildOutput));
   desktopPane.add(buildOutputFrame);
   buildOutputFrame.setLocation(0, 0);
   buildOutputFrame.setSize(desktopPane.getSize());
   buildOutputFrame.setVisible(true);
 }
  /**
   * MouseListener implementation. Shows an internal frame with the picture of the player whose
   * label was clicked.
   */
  public void mouseClicked(MouseEvent evt) {
    Object source = evt.getSource();

    if ((source == whiteLabel) || (source == blackLabel)) {
      String name = (source == whiteLabel ? getGame().getWhiteName() : getGame().getBlackName());
      URL url;
      try {
        url = new URL("http://www.chessclub.com/mugshots/" + name + ".jpg");
      } catch (MalformedURLException e) {
        e.printStackTrace();
        return;
      }

      JInternalFrame frame = new UserImageInternalFrame(url, name);
      frame.setLocation(0, 0);
      JDesktopPane desktop = boardManager.getPluginContext().getMainFrame().getDesktop();
      desktop.add(frame, JLayeredPane.PALETTE_LAYER);
      frame.setSize(frame.getPreferredSize());
      frame.setVisible(true);
      frame.toFront();
    }
  }
Exemplo n.º 13
0
  /**
   * Will update the triangle given the absolute location of the center of the moveButton.
   *
   * @author achang, adapted from code by susiefu
   */
  public void updateTriangle(int x, int y) {

    Point realLocation = new Point(x, y);
    Dimension editFrameSize = editFrame.getSize();
    Point editFrameLocation = editFrame.getLocation();
    //        new Point(realLocation.x - editFrameSize.width + buttonFrame.getWidth()*3/4,
    //        realLocation.y + buttonFrame.getHeight()/2);
    int X_FUDGE = 15;
    int Y_FUDGE = 5;
    int tribase =
        (Math.round((Math.min(editFrameSize.width, editFrameSize.height))) / 10 > TRIANGLE_BASE)
            ? Math.round((Math.min(editFrameSize.width, editFrameSize.height))) / 10
            : TRIANGLE_BASE;
    int tilt = -1;
    int cellX = getCellCenter().x;
    int cellY = getCellCenter().y;
    //    System.out.println("kCW >> updateTriangle >> cellCenter="+getCellCenter());
    int width, height;

    if (editFrameLocation.x + editFrameSize.width / 2 >= cellX
        && editFrameLocation.x - X_FUDGE <= cellX
        && editFrameLocation.y >= cellY) { // Right , bottom (DEFAULT)
      direction = "SE";
      height = editFrameLocation.y - cellY;
      if (editFrameLocation.x >= cellX) {
        tilt = 0; // Pointing left
        width = Math.abs(editFrameLocation.x - cellX) + tribase;
      } else {
        tilt = 1; // Pointing right
        if (Math.abs(editFrameLocation.x - cellX) > tribase) {
          width = Math.abs(editFrameLocation.x - cellX);
        } else {
          width = tribase;
        }
      }
    } else if (editFrameLocation.x + editFrameSize.width / 2 < cellX
        && editFrameLocation.x + editFrameSize.width > cellX
        && editFrameLocation.y >= cellY + Y_FUDGE) { // Middle,
      // bottom
      direction = "S"; // SAME CODE AS "SE" DIRECTION BECAUSE OF OVERLAPPING
      // OF BUTTONS AND TRIANGLE
      height = editFrameLocation.y - cellY;
      if (editFrameLocation.x >= cellX) {
        tilt = 0; // Pointing left
        width = Math.abs(editFrameLocation.x - cellX) + tribase;
      } else {
        tilt = 1; // Pointing right
        if (Math.abs(editFrameLocation.x - cellX) > tribase) {
          width = Math.abs(editFrameLocation.x - cellX);
        } else {
          width = tribase;
        }
      }

    } else if (editFrameLocation.x + editFrameSize.width <= cellX
            && editFrameLocation.y + editFrameSize.height + 3 * Y_FUDGE >= cellY
        || editFrameLocation.x + 3 * editFrameSize.width / 2 < cellX
            && editFrameLocation.y + editFrameSize.height < cellY) { // Left, middle

      direction = "W";
      width = Math.abs(editFrameLocation.x + editFrameSize.width - cellX);
      if (editFrameLocation.y >= cellY) {
        tilt = 0; // Pointing up
        height = Math.abs(editFrameLocation.y - cellY) + tribase;
      } else {
        tilt = 1; // Pointing down
        if (Math.abs(editFrameLocation.y - cellY) > tribase) {
          height = Math.abs(editFrameLocation.y - cellY);
        } else {
          height = tribase;
        }
      }

    } else if (editFrameLocation.x + editFrameSize.width / 2 <= cellX
        && editFrameLocation.x + 3 * editFrameSize.width / 2 >= cellX
        && editFrameLocation.y + editFrameSize.height + 3 * Y_FUDGE < cellY) { // Left,
      // top
      direction = "NW";
      height = Math.abs(editFrameLocation.y + editFrameSize.height - cellY);
      if (editFrameLocation.x + editFrameSize.width > cellX) {
        tilt = 0; // Pointing left
        if (Math.abs(editFrameLocation.x + editFrameSize.width - cellX) > tribase) {
          width = Math.abs(editFrameLocation.x + editFrameSize.width - cellX);
        } else {
          width = tribase;
        }

      } else {
        tilt = 1; // Pointing right
        width = Math.abs(editFrameLocation.x + editFrameSize.width - cellX) + tribase;
      }

    } else if (editFrameLocation.x + editFrameSize.width / 2 > cellX
        && editFrameLocation.x - editFrameSize.width / 2 <= cellX
        && editFrameLocation.y + editFrameSize.height + Y_FUDGE < cellY) { // Middle,
      // top
      direction = "N";
      height = Math.abs(editFrameLocation.y + editFrameSize.height - cellY);
      if (editFrameLocation.x >= cellX) {
        tilt = 0; // Pointing left
        width = Math.abs(editFrameLocation.x - cellX) + tribase;
      } else {
        tilt = 1; // Pointing right
        if (Math.abs(editFrameLocation.x - cellX) > tribase) {
          width = Math.abs(editFrameLocation.x - cellX);
        } else {
          width = tribase;
        }
      }

    } else if (editFrameLocation.x - X_FUDGE > cellX
        || editFrameLocation.y - editFrameSize.height / 2 >= cellY
            && editFrameLocation.x - X_FUDGE <= cellX) { // Right, middle
      direction = "E";
      width = Math.abs(editFrameLocation.x - cellX);
      if (editFrameLocation.y >= cellY) {
        tilt = 0; // Pointing up
        height = Math.abs(editFrameLocation.y - cellY) + tribase;
      } else {
        tilt = 1; // Pointing down
        if (Math.abs(editFrameLocation.y - cellY) > tribase) {
          height = Math.abs(editFrameLocation.y - cellY);
        } else {
          height = tribase;
        }
      }

    } else {
      direction = "NONE";
      height = editFrameLocation.y - cellY;
      if (editFrameLocation.x >= cellX) {
        tilt = 0;
        width = Math.abs(editFrameLocation.x - cellX) + tribase;
      } else {
        tilt = 1;
        if (Math.abs(editFrameLocation.x - cellX) > tribase) {
          width = Math.abs(editFrameLocation.x - cellX);
        } else {
          width = tribase;
        }
      }
    }
    triangleFrame.setSize(width, height);
    ((Triangle) triangleFrame.getContentPane())
        .setGeometry(direction, tilt, width, height, tribase);
    setFrameGeometry(
        direction,
        tilt,
        realLocation.x - editFrameSize.width + buttonFrame.getWidth() * 3 / 4,
        realLocation.y - buttonFrame.getWidth() / 2);
  }
Exemplo n.º 14
0
  /**
   * Constructor: The one we're working on right now.
   *
   * @param id
   * @param label
   * @param desktop
   */
  public kCodeWindow(String id, String label, JDesktopPane desktop) {

    this.id = id;
    this.desktop = desktop;

    // make the editor portions

    TextAreaDefaults editareaSettings = new PdeTextAreaDefaults();
    editareaSettings.rows = TEXTAREA_DEFAULT_ROWS;
    editareaSettings.cols = TEXTAREA_DEFAULT_COLS;
    textarea = new JEditTextArea(editareaSettings);
    textarea.getDocument().setTokenMarker(Editor.pdeTokenMarker);
    textarea.setEventsEnabled(
        false); // suppress JEditTextArea events (not that anyone is listening to it)
    textarea.setEditable(true);
    textarea.setHorizontalOffset(TEXTAREA_HORIZ_OFFSET);
    textarea.getPainter().setLineHighlightEnabled(false); // else looks funny
    textarea.getPainter().setBackground(kConstants.CODE_WINDOW_COLOR);
    setShortcutKeystrokes();
    JScrollPane scrollPane = new JScrollPane(textarea);
    scrollPane.setBorder(null);
    //    scrollPane.setOpaque(true);

    editFrame = new JInternalFrame(label, true, false, false, false);
    editFrame.setContentPane(textarea);
    editFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    editFrame.setSize(editFrame_DEFAULT_WIDTH, editFrame_DEFAULT_HEIGHT);
    editFrame.setBorder(null);
    editFrame.setOpaque(true);

    // make the triangle
    triangleFrame = new JInternalFrame("", false, false, false, false);
    triangleFrame.setOpaque(false);
    triangleFrame
        .getRootPane()
        .setBackground(new Color(0, 0, 0, 0)); // needs this to actually do the trick
    triangleFrame.setContentPane(
        new Triangle("SE", 0, TRIANGLE_BASE, TRIANGLE_DEFAULT_HEIGHT, TRIANGLE_BASE));
    triangleFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    triangleFrame.setSize(TRIANGLE_BASE, TRIANGLE_DEFAULT_HEIGHT);
    triangleFrame.setBorder(null);

    // remove the ability to move the triangle iframe
    MouseMotionListener[] actions =
        (MouseMotionListener[]) triangleFrame.getListeners(MouseMotionListener.class);
    for (int i = 0; i < actions.length; i++) triangleFrame.removeMouseMotionListener(actions[i]);

    // make the buttons
    moveButton = new JButton(Base.getImageIcon("codewindow-activ-move.gif", desktop));
    moveButton.setDisabledIcon(Base.getImageIcon("codewindow-inact-move.gif", desktop));
    moveButton.setVisible(true);
    moveButton.setBorder(null);
    moveButton.setOpaque(false);
    moveButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    closeButton = new JButton(Base.getImageIcon("codewindow-activ-close.gif", desktop));
    closeButton.setDisabledIcon(Base.getImageIcon("codewindow-inact-close.gif", desktop));
    closeButton.setVisible(true);
    closeButton.setBorder(null);
    closeButton.setOpaque(false);
    closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 0));
    buttonPanel.setBorder(null);
    buttonPanel.setOpaque(false);
    buttonPanel.add(moveButton);
    buttonPanel.add(closeButton);

    buttonFrame = new JInternalFrame("", false, false, false, false);
    buttonFrame.setContentPane(buttonPanel);
    buttonFrame.setOpaque(false);
    buttonFrame.getRootPane().setBackground(new Color(0, 0, 0, 0));
    buttonFrame.setSize(BUTTON_ICON_WIDTH * 2 + BUTTON_GAP, BUTTON_ICON_HEIGHT);
    buttonFrame.setBorder(null);

    // myriad event handling

    installFocusHandlers(buttonPanel);

    // hide code window when escape key is hit
    textarea.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) setVisible(false);
          }
        });
    // add dragging function of the move button,
    // reset the triangle after mouse release, and shift the editFrame
    // along with the mouse when the user is moving the window
    mxMouseControl moveListener = createMoveListener();
    moveButton.addMouseListener(moveListener);
    moveButton.addMouseMotionListener(moveListener);
    closeButton.addMouseListener(createCloseListener());
    // listens to resizing of editFrame and adjusts the position of the
    // buttons and the shape of the triangle accordingly
    editFrame.addComponentListener(createResizeListener());
    // when code windows are on top of each other, layers them correctly
    // such that when the user clicks on any part of a code window
    // all three component internal frames are brought to the top
    // so they appear "focused" also
    InternalFrameListener iframeListener =
        new InternalFrameAdapter() {
          public void internalFrameActivated(InternalFrameEvent e) {
            moveToFrontLayer();
          }

          public void internalFrameDeactivated(InternalFrameEvent e) {
            moveToBackLayer();
          }
        };
    editFrame.addInternalFrameListener(iframeListener);
    buttonFrame.addInternalFrameListener(iframeListener);
    triangleFrame.addInternalFrameListener(iframeListener);

    // add everything to desktop

    desktop.add(editFrame);
    desktop.add(buttonFrame);
    desktop.add(triangleFrame);
    moveToBackLayer();
  }
    public void actionPerformed(ActionEvent e) {
      JDesktopPane dp = (JDesktopPane) e.getSource();
      String key = getName();

      if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key || RESTORE == key) {
        setState(dp, key);
      } else if (ESCAPE == key) {
        if (sourceFrame == dp.getSelectedFrame() && focusOwner != null) {
          focusOwner.requestFocus();
        }
        moving = false;
        resizing = false;
        sourceFrame = null;
        focusOwner = null;
      } else if (MOVE == key || RESIZE == key) {
        sourceFrame = dp.getSelectedFrame();
        if (sourceFrame == null) {
          return;
        }
        moving = (key == MOVE) ? true : false;
        resizing = (key == RESIZE) ? true : false;

        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (!SwingUtilities.isDescendingFrom(focusOwner, sourceFrame)) {
          focusOwner = null;
        }
        sourceFrame.requestFocus();
      } else if (LEFT == key
          || RIGHT == key
          || UP == key
          || DOWN == key
          || SHRINK_RIGHT == key
          || SHRINK_LEFT == key
          || SHRINK_UP == key
          || SHRINK_DOWN == key) {
        JInternalFrame c = dp.getSelectedFrame();
        if (sourceFrame == null
            || c != sourceFrame
            || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()
                != sourceFrame) {
          return;
        }
        Insets minOnScreenInsets = UIManager.getInsets("Desktop.minOnScreenInsets");
        Dimension size = c.getSize();
        Dimension minSize = c.getMinimumSize();
        int dpWidth = dp.getWidth();
        int dpHeight = dp.getHeight();
        int delta;
        Point loc = c.getLocation();
        if (LEFT == key) {
          if (moving) {
            c.setLocation(
                loc.x + size.width - MOVE_RESIZE_INCREMENT < minOnScreenInsets.right
                    ? -size.width + minOnScreenInsets.right
                    : loc.x - MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (RIGHT == key) {
          if (moving) {
            c.setLocation(
                loc.x + MOVE_RESIZE_INCREMENT > dpWidth - minOnScreenInsets.left
                    ? dpWidth - minOnScreenInsets.left
                    : loc.x + MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (UP == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + size.height - MOVE_RESIZE_INCREMENT < minOnScreenInsets.bottom
                    ? -size.height + minOnScreenInsets.bottom
                    : loc.y - MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (DOWN == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + MOVE_RESIZE_INCREMENT > dpHeight - minOnScreenInsets.top
                    ? dpHeight - minOnScreenInsets.top
                    : loc.y + MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (SHRINK_LEFT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + size.width - delta < minOnScreenInsets.left) {
            delta = loc.x + size.width - minOnScreenInsets.left;
          }
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_RIGHT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + delta > dpWidth - minOnScreenInsets.right) {
            delta = (dpWidth - minOnScreenInsets.right) - loc.x;
          }

          c.setLocation(loc.x + delta, loc.y);
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_UP == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + size.height - delta < minOnScreenInsets.bottom) {
            delta = loc.y + size.height - minOnScreenInsets.bottom;
          }

          c.setSize(size.width, size.height - delta);
        } else if (SHRINK_DOWN == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + delta > dpHeight - minOnScreenInsets.top) {
            delta = (dpHeight - minOnScreenInsets.top) - loc.y;
          }

          c.setLocation(loc.x, loc.y + delta);
          c.setSize(size.width, size.height - delta);
        }
      } else if (NEXT_FRAME == key || PREVIOUS_FRAME == key) {
        dp.selectFrame((key == NEXT_FRAME) ? true : false);
      } else if (NAVIGATE_NEXT == key || NAVIGATE_PREVIOUS == key) {
        boolean moveForward = true;
        if (NAVIGATE_PREVIOUS == key) {
          moveForward = false;
        }
        Container cycleRoot = dp.getFocusCycleRootAncestor();

        if (cycleRoot != null) {
          FocusTraversalPolicy policy = cycleRoot.getFocusTraversalPolicy();
          if (policy != null && policy instanceof SortingFocusTraversalPolicy) {
            SortingFocusTraversalPolicy sPolicy = (SortingFocusTraversalPolicy) policy;
            boolean idc = sPolicy.getImplicitDownCycleTraversal();
            try {
              sPolicy.setImplicitDownCycleTraversal(false);
              if (moveForward) {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(dp);
              } else {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(dp);
              }
            } finally {
              sPolicy.setImplicitDownCycleTraversal(idc);
            }
          }
        }
      }
    }
Exemplo n.º 16
0
  // ´°¿ÚµÄ»ù±¾ÅäÖÃ
  public void initWindow() {
    dispose();
    setUndecorated(true);
    setRootPaneCheckingEnabled(false);
    setSize(380, 296);
    setResizable(false);
    javax.swing.plaf.InternalFrameUI jf = jif.getUI();
    ((javax.swing.plaf.basic.BasicInternalFrameUI) jf).setNorthPane(null);
    jif.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 2));
    jif.setSize(380, 296);
    jif.setEnabled(false);

    jsetup.setBounds(287, -2, 28, 20);
    jclose.setBounds(343, -2, 39, 20);
    jmin.setBounds(315, -2, 28, 20);
    jif.getContentPane().add(jsetup);
    jif.getContentPane().add(jclose);
    jif.getContentPane().add(jmin);

    setJLabel(header);
    header.setBounds(20, 140, 87, 87);
    jif.getContentPane().add(header);

    setJLabel(photo);
    photo.setBounds(23, 142, 83, 83);
    jif.getContentPane().add(photo);

    userInput.setBounds(118, 142, 188, 25);
    userInput.setEditable(true);
    userInput.setFont(new Font("Times New Roman", 0, 14));
    jif.getContentPane().add(userInput);

    setJLabel(register);
    register.setBounds(316, 144, 51, 16);
    jif.getContentPane().add(register);

    pwdInput.setBounds(118, 175, 188, 25);
    jif.getContentPane().add(pwdInput);

    setJLabel(minaFind);
    minaFind.setBounds(316, 178, 51, 16);
    jif.getContentPane().add(minaFind);

    remPwd.setBounds(117, 210, 72, 16);
    jif.getContentPane().add(remPwd);
    setJCheckbox(remPwd);

    autoLogin.setBounds(202, 210, 72, 16);
    jif.getContentPane().add(autoLogin);
    setJCheckbox(autoLogin);

    setJLabel(swit);
    swit.setBounds(15, 255, 25, 25);
    jif.getContentPane().add(swit);

    setButton(jlogin);
    jlogin.setBounds(115, 247, 165, 40);
    jlogin.setFont(new Font("ËÎÌå", 0, 12));
    jlogin.setIconTextGap(-108);
    jif.getContentPane().add(jlogin);

    setJLabel(right);
    right.setBounds(333, 248, 38, 38);
    jif.getContentPane().add(right);

    setJLabel(state);
    state.setBounds(92, 210, 11, 11);
    jif.getContentPane().add(state, 3);

    setWindowDray(jif);
    jif.getContentPane().add(bg);
    getContentPane().add(jif);
    setLocation(
        (Toolkit.getDefaultToolkit().getScreenSize().width - getSize().width) / 2,
        (Toolkit.getDefaultToolkit().getScreenSize().height - getSize().height) / 2);
    setButton(jsetup);
    setButton(jclose);
    setButton(jmin);

    this.setTitle("PQQ-http://www.yanyulin.info");
    this.setIconImage(new ImageIcon(getClass().getResource("pics/xiaomi.jpg")).getImage());
    setAlwaysOnTop(true);
    jif.setVisible(true);
    setVisible(true);
  }
Exemplo n.º 17
0
  /**
   * Method to handle hyper link events.
   *
   * @param event hyper link event
   */
  public void hyperlinkUpdate(HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      setCursor(cbusy);
      try {
        URL url = event.getURL();

        int ind1 = event.getDescription().indexOf("[");
        int ind2 = event.getDescription().lastIndexOf("]");

        String search = "";
        if (ind1 > -1 && ind2 > -1) search = event.getDescription().substring(ind1 + 1, ind2);
        else {
          ind1 = event.getDescription().indexOf("=") + 1; // genedb
          if (ind1 > -1) search = event.getDescription().substring(ind1);
        }

        if (desktop != null) {
          if (BigPane.srsTabPane.isSelected()) setUpSRSFrame(url, search);

          if (BigPane.srsWin.isSelected()) {
            int hgt = (2 * desktop.getHeight()) / 3;
            Annotation edPane = new Annotation(url);
            JScrollPane jsp = new JScrollPane(edPane);
            JInternalFrame jif =
                new JInternalFrame(
                    "SRS " + search,
                    true, // resizable
                    true, // closable
                    true, // maximizable
                    true); // iconifiable);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(new CommonMenu(jif));
            jif.setJMenuBar(menuBar);
            jif.getContentPane().add(jsp);
            jif.setLocation(0, 0);
            jif.setSize(800, hgt);
            jif.setVisible(true);
            desktop.add(jif);
          }

          if (BigPane.srsBrowser.isSelected()) BrowserControl.displayURL(event.getDescription());
        } else {
          setPage(url);
          back.add(url);
        }
      } catch (IOException ioe) {
        String msg = event.getDescription();
        if (msg.length() > 50) msg = msg.substring(0, 50) + "....";

        JOptionPane.showMessageDialog(
            this, "Cannot reach URL:\n" + msg, "Cannot Connect", JOptionPane.INFORMATION_MESSAGE);
        //      ioe.printStackTrace();
        //      ("Can't follow link to " +
        //                event.getURL().toExternalForm() );
      }

      setCursor(cdone);
    } else if (event.getEventType() == HyperlinkEvent.EventType.ENTERED) {
      try {
        JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1);
        statusField.setText(event.getDescription());
      } catch (Exception exp) {
      }

    } else if (event.getEventType() == HyperlinkEvent.EventType.EXITED) {
      try {
        JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1);
        statusField.setText("");
      } catch (Exception exp) {
      }
    }
  }
Exemplo n.º 18
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }