Ejemplo n.º 1
0
 private void synchronizeCompatibleProductViews() {
   final ProductSceneView currentView = getCurrentView();
   if (currentView == null) {
     return;
   }
   final JInternalFrame[] internalFrames = VisatApp.getApp().getAllInternalFrames();
   for (final JInternalFrame internalFrame : internalFrames) {
     if (internalFrame.getContentPane() instanceof ProductSceneView) {
       final ProductSceneView view = (ProductSceneView) internalFrame.getContentPane();
       if (view != currentView) {
         currentView.synchronizeViewport(view);
       }
     }
   }
 }
  /**
   * Adds a component to the middle layer of the desktop--that is, the layer for session node
   * editors. Note: The comp is a SessionEditor
   */
  public void addSessionEditor(SessionEditorIndirectRef editorRef) {
    SessionEditor editor = (SessionEditor) editorRef;

    JInternalFrame frame = new TetradInternalFrame(null);

    frame.getContentPane().add(editor);
    framesMap.put(editor, frame);
    editor.addPropertyChangeListener(this);

    // Set the "small" size of the frame so that it has sensible
    // bounds when the users unmazimizes it.
    Dimension fullSize = desktopPane.getSize();
    int smallSize = Math.min(fullSize.width - MARGIN, fullSize.height - MARGIN);
    Dimension size = new Dimension(smallSize, smallSize);
    setGoodBounds(frame, desktopPane, size);
    desktopPane.add(frame);

    // Set the frame to be maximized. This step must come after the frame
    // is added to the desktop. -Raul. 6/21/01
    try {
      frame.setMaximum(true);
    } catch (Exception e) {
      throw new RuntimeException("Problem setting frame to max: " + frame);
    }

    desktopPane.setLayer(frame, 0);
    frame.moveToFront();
    frame.setTitle(editor.getName());
    frame.setVisible(true);

    setMainTitle(editor.getName());
  }
 public void xtestTiming() {
   final JDialog dialog = new JDialog((JFrame) null, "TestTiming");
   JDesktopPane pane = new JDesktopPane();
   dialog.setContentPane(pane);
   final Object[] f = {null};
   for (int i = 99; i >= 0; i--) {
     JInternalFrame frame = new JInternalFrame("Internal Frame - " + i, true, true, true, true);
     JButton s = new JButton("button" + i);
     s.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             final long start = System.currentTimeMillis();
             System.err.println("TestMarathonNamingStrategy.testTiming(): " + start);
             namingStrategy.setTopLevelComponent(dialog, true);
             String name = namingStrategy.getName((Component) e.getSource());
             System.err.println(
                 "TestMarathonNamingStrategy.testTiming(): name = "
                     + name
                     + "::"
                     + (System.currentTimeMillis() - start));
           }
         });
     f[0] = s;
     frame.getContentPane().add(s);
     frame.pack();
     frame.setLocation(i, i);
     frame.setVisible(true);
     pane.add(frame);
   }
   dialog.setSize(500, 500);
   dialog.setModal(true);
   dialog.setVisible(true);
   System.err.println(
       "TestMarathonNamingStrategy.testTiming(): " + ((Component) f[0]).isVisible());
 }
Ejemplo n.º 4
0
  public LogViewInternalFrame(
      String name, JDesktopPane desktopPane, StatusObserver statusObserver) {
    this.name = name;
    this.desktopPane = desktopPane;
    this.statusObserver = statusObserver;
    dataTableModel = new LogDataTableModel();
    logViewPanel = new LogViewPanel(dataTableModel, statusObserver);

    cardLayout = new CardLayout();
    JPanel panelLoading = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(10, 10, 10, 10);
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.ipadx = 12;
    c.ipady = 12;
    JLabel label = new JLabel("Loading file " + name);
    panelLoading.add(label, c);

    c.gridy = 1;
    c.weighty = 5;
    c.weightx = 3;

    loadingProgressBar = new JProgressBar();
    loadingProgressBar.setIndeterminate(false);
    loadingProgressBar.setStringPainted(true);
    loadingProgressBar.setString("Connecting...");
    panelLoading.add(loadingProgressBar, c);

    iframe = new JInternalFrame(name, true, true, true, true);
    iframe.getContentPane().setLayout(cardLayout);
    iframe.getContentPane().add(panelLoading, CARD_LAYOUT_LOADING);
    iframe.getContentPane().add(logViewPanel, CARD_LAYOUT_CONTENT);
    cardLayout.show(iframe.getContentPane(), CARD_LAYOUT_LOADING);
    iframe.setBounds(50, 50, 200, 100);
    desktopPane.add(iframe);

    iframe.setVisible(true);
    iframe.pack();
    try {
      iframe.setMaximum(true);
    } catch (PropertyVetoException ignore) {
    }
  }
 public void testContextIsJFrameWhenInternalFrameIsShown() {
   JFrame frame = new JFrame();
   JInternalFrame internalFrame = new JInternalFrame();
   JTextField textField = new JTextField();
   setFocusManager(textField);
   internalFrame.getContentPane().add(textField);
   frame.getContentPane().add(internalFrame);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, textField));
   assertSame(frame, windowContext.activeWindow());
   assertSame(frame, windowContext.activeTopLevelWindow());
 }
  public void test_update() throws Exception {
    JInternalFrame frame = new JInternalFrame("Options");
    JTextField source = new JTextField();
    frame.getContentPane().add(source);

    assertContext.setGuiComponent(GuiComponentFactory.newGuiComponent(source));

    assertFrame.update();

    assertEquals("AssertFrame titre='Options'", assertFrame.getValue(AssertFrame.LABEL));
  }
Ejemplo n.º 7
0
 MyDesktop() {
   // fr1 = new JInternalFrame("FlowLayout", true, true);
   fr1.setBounds(10, 10, 150, 150);
   Container c = fr1.getContentPane();
   c.setLayout(new FlowLayout());
   c.add(new JButton("1"));
   c.add(new JButton("2"));
   c.add(new JButton("3"));
   c.add(new JButton("4"));
   add(fr1, 0);
 }
Ejemplo n.º 8
0
 /** Builds the main customer Frame */
 private void createCustomerInternalFrame() {
   {
     jInternalFrameCustomerDetails = new JInternalFrame("Details");
     jInternalFrameCustomerDetails.setLayout(new BorderLayout());
     buildJPanelCustomerDetails(customer);
     jInternalFrameCustomerDetails.getContentPane().add(jPanelCustomerDetails, BorderLayout.WEST);
     jInternalFrameCustomerDetails.setVisible(true);
     jInternalFrameCustomerDetails.setBounds(1, 1, 497, 410);
     jInternalFrameCustomerDetails.setPreferredSize(new java.awt.Dimension(497, 410));
   }
 }
Ejemplo n.º 9
0
 protected void showDeployAgentDialog() {
   // TODO Auto-generated method stub
   JInternalFrame fr = new JInternalFrame("Deploy Agent");
   fr.getContentPane().add(new NewAgentPanel());
   fr.pack();
   fr.setClosable(true);
   fr.setIconifiable(true);
   fr.setResizable(true);
   fr.setMaximizable(true);
   fr.setVisible(true);
   jDesktopPane1.add(fr);
 }
Ejemplo n.º 10
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);
 }
Ejemplo n.º 11
0
 @Override
 protected JComponent createControl() {
   JComponent pageComponentControl = getPageComponent().getControl();
   if (pageComponentControl.getName() == null) {
     nameComponent(pageComponentControl, "Control");
   }
   internalFrame = new JInternalFrame();
   configureControl();
   internalFrame.getContentPane().add(pageComponentControl, BorderLayout.CENTER);
   internalFrame.addInternalFrameListener(new InternalFrameHandler());
   nameComponent(internalFrame, "Pane");
   return internalFrame;
 }
Ejemplo n.º 12
0
  /** Returns true iff there exist a session in the desktop. */
  private boolean existsSession() {
    JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0);

    for (JInternalFrame allFrame : allFrames) {
      Object o = allFrame.getContentPane().getComponents()[0];

      if (o instanceof SessionEditor) {
        return true;
      }
    }

    return false;
  }
Ejemplo n.º 13
0
  public SessionEditor getFrontmostSessionEditor() {
    JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0);

    if (allFrames.length == 0) {
      return null;
    }

    JInternalFrame frontmostFrame = allFrames[0];
    Object o = frontmostFrame.getContentPane().getComponents()[0];

    boolean isSessionEditor = o instanceof SessionEditor;
    return isSessionEditor ? (SessionEditor) o : null;
  }
Ejemplo n.º 14
0
  public void closeEmptySessions() {
    JInternalFrame[] frames = desktopPane.getAllFramesInLayer(0);

    for (JInternalFrame frame : frames) {
      Object o = frame.getContentPane().getComponents()[0];

      if (o instanceof SessionEditor) {
        SessionEditor sessionEditor = (SessionEditor) o;
        SessionEditorWorkbench workbench = sessionEditor.getSessionWorkbench();
        Graph graph = workbench.getGraph();
        if (graph.getNumNodes() == 0) {
          frame.dispose();
        }
      }
    }
  }
Ejemplo n.º 15
0
  public boolean existsSessionByName(String filename) {
    JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0);

    for (JInternalFrame allFrame : allFrames) {
      Object o = allFrame.getContentPane().getComponents()[0];

      if (o instanceof SessionEditor) {
        SessionEditor editor = (SessionEditor) o;

        String editorName = editor.getName();
        if (editorName.equals(filename)) {
          return true;
        }
      }
    }

    return false;
  }
Ejemplo n.º 16
0
 private void showDomainDialog(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_showDomainDialog
   // TODO add your handling code here:
   JInternalFrame fr = new JInternalFrame("Add new Domain");
   fr.getContentPane().add(new NewDomainPanel());
   fr.pack();
   fr.setClosable(true);
   fr.setIconifiable(true);
   fr.setResizable(true);
   fr.setMaximizable(true);
   fr.setVisible(true);
   jDesktopPane1.add(fr);
   GridBagConstraints gc = new GridBagConstraints();
   gc.gridx = 0;
   gc.gridy = GridBagConstraints.RELATIVE;
   gc.insets = new Insets(6, 12, 0, 12);
   gc.fill = GridBagConstraints.HORIZONTAL;
   domainsPanel.add(new JButton("Dynamic"), gc);
 } // GEN-LAST:event_showDomainDialog
Ejemplo n.º 17
0
  // aqui se añade los internalframe al destop pane
  private void agregarMarcoInterno(JInternalFrame marco) {

    marco.setLocation(xSigMarco, ySigMarco);
    marco.setVisible(true);
    jDesktopPane.add(marco);

    try {
      marco.setSelected(true);
    } catch (PropertyVetoException ex) {
    }

    if (distanciaEntreMarcos == 0)
      distanciaEntreMarcos = marco.getHeight() - marco.getContentPane().getHeight();

    xSigMarco += distanciaEntreMarcos;
    ySigMarco += distanciaEntreMarcos;
    if (xSigMarco + marco.getWidth() > jDesktopPane.getWidth()) xSigMarco = 0;
    if (ySigMarco + marco.getHeight() > jDesktopPane.getHeight()) ySigMarco = 0;
  }
 /**
  * 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);
 }
Ejemplo n.º 19
0
 private void rasterDataNodeSelected(final RasterDataNode raster, final int clickCount) {
   setSelectedProductNode(raster);
   final JInternalFrame[] internalFrames = visatApp.findInternalFrames(raster);
   JInternalFrame frame = null;
   for (final JInternalFrame internalFrame : internalFrames) {
     final int numRasters = ((ProductSceneView) internalFrame.getContentPane()).getNumRasters();
     if (numRasters == 1) {
       frame = internalFrame;
       break;
     }
   }
   if (frame != null) {
     try {
       frame.setSelected(true);
     } catch (PropertyVetoException ignored) {
       // ok
     }
   } else if (clickCount == 2) {
     final ExecCommand command = visatApp.getCommandManager().getExecCommand("showImageView");
     command.execute(clickCount);
   }
 }
Ejemplo n.º 20
0
  /** Contains a CyNetworkView. */
  protected void createContainer(final CyNetworkView view) {
    if (networkViewMap.containsKey(view.getNetwork().getIdentifier())) return;

    // create a new InternalFrame and put the CyNetworkViews Component into
    // it
    final JInternalFrame iframe = new JInternalFrame(view.getTitle(), true, true, true, true);
    iframe.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameClosing(InternalFrameEvent e) {
            Cytoscape.destroyNetworkView(view);
          }
        });
    desktopPane.add(iframe);

    // code added to support layered canvas for each CyNetworkView
    if (view instanceof DGraphView) {
      final InternalFrameComponent internalFrameComp =
          new InternalFrameComponent(iframe.getLayeredPane(), (DGraphView) view);

      iframe.getContentPane().add(internalFrameComp);
      internalFrameComponentMap.put(view.getNetwork().getIdentifier(), internalFrameComp);
    } else {
      logger.info("NetworkViewManager.createContainer() - DGraphView not found!");
      iframe.getContentPane().add(view.getComponent());
    }

    iframe.pack();

    int x = 0;
    int y = 0;
    JInternalFrame refFrame = null;
    JInternalFrame[] allFrames = desktopPane.getAllFrames();

    if (allFrames.length > 1) {
      refFrame = allFrames[0];
    }

    if (refFrame != null) {
      x = refFrame.getLocation().x + 20;
      y = refFrame.getLocation().y + 20;
    }

    if (x > (desktopPane.getWidth() - MINIMUM_WIN_WIDTH)) {
      x = desktopPane.getWidth() - MINIMUM_WIN_WIDTH;
    }

    if (y > (desktopPane.getHeight() - MINIMUM_WIN_HEIGHT)) {
      y = desktopPane.getHeight() - MINIMUM_WIN_HEIGHT;
    }

    if (x < 0) {
      x = 0;
    }

    if (y < 0) {
      y = 0;
    }

    iframe.setBounds(x, y, 400, 400);

    // maximize the frame if the specified property is set
    try {
      String max = CytoscapeInit.getProperties().getProperty("maximizeViewOnCreate");

      if ((max != null) && Boolean.parseBoolean(max)) iframe.setMaximum(true);
    } catch (PropertyVetoException pve) {
      logger.warn("Unable to maximize internal frame: " + pve.getMessage());
    }

    iframe.setVisible(true);
    iframe.addInternalFrameListener(this);
    iframe.setResizable(true);

    networkViewMap.put(view.getNetwork().getIdentifier(), iframe);
    componentMap.put(iframe, view.getNetwork().getIdentifier());

    firePropertyChange(
        CytoscapeDesktop.NETWORK_VIEW_FOCUSED, null, view.getNetwork().getIdentifier());
  }
Ejemplo n.º 21
0
 public void switchToContentView() {
   cardLayout.show(iframe.getContentPane(), CARD_LAYOUT_CONTENT);
 }
Ejemplo n.º 22
0
  /** The graphic handling and deployment. */
  private void initComponents() {
    jDesktopPane1 = new javax.swing.JDesktopPane();
    jInternalFrame1 = new javax.swing.JInternalFrame();
    tf = new javax.swing.JTextField();
    b1 = new javax.swing.JButton();
    jInternalFrame3 = new javax.swing.JInternalFrame();
    ta = new javax.swing.JTextArea();
    jsp_ta = new javax.swing.JScrollPane(ta);
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    jMenuItem4 = new javax.swing.JMenuItem();

    jInternalFrame1
        .getContentPane()
        .setLayout(
            new javax.swing.BoxLayout(
                jInternalFrame1.getContentPane(), javax.swing.BoxLayout.X_AXIS));

    jInternalFrame1.setIconifiable(true);
    jInternalFrame1.setMaximizable(true);
    jInternalFrame1.setResizable(true);
    jInternalFrame1.setTitle("Message editor");
    jInternalFrame1.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame1.setVisible(true);
    tf.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    jInternalFrame1.getContentPane().add(tf);

    b1.setText("Send Message");
    jInternalFrame1.getContentPane().add(b1);

    jInternalFrame1.setBounds(10, 10, 440, 60);
    jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

    jInternalFrame3.setIconifiable(true);
    jInternalFrame3.setMaximizable(true);
    jInternalFrame3.setResizable(true);
    jInternalFrame3.setTitle("Messages");
    jInternalFrame3.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame3.setVisible(true);
    ta.setBackground(new Color(255, 255, 255));
    ta.setEditable(false);
    ta.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    // jsp_ta.setAutoscrolls(true);
    jsp_ta.setDoubleBuffered(true);

    jInternalFrame3.getContentPane().add(jsp_ta, java.awt.BorderLayout.CENTER);

    jInternalFrame3.setBounds(10, 80, 420, 240);

    jDesktopPane1.add(jInternalFrame3, javax.swing.JLayeredPane.DEFAULT_LAYER);

    getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);

    jMenu1.setText("Private room options");
    jMenu1.setMnemonic(KeyEvent.VK_O);
    jMenu1.setToolTipText("Choose some options.");
    jMenuItem3.setText("Save conversation");
    jMenuItem3.setMnemonic(KeyEvent.VK_S);
    jMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem3);
    jMenu1.add(jSeparator1);
    jMenuItem4.setText("Exit");
    jMenuItem4.setMnemonic(KeyEvent.VK_E);
    jMenuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem4);
    jMenuBar1.add(jMenu1);
    setJMenuBar(jMenuBar1);

    this.pack();

    b1.addActionListener(this);
    tf.addActionListener(this);
    jMenuItem3.addActionListener(this);
    jMenuItem4.addActionListener(this);

    posx = (int) Math.random() * 640;
    posy = (int) Math.random() * 480;

    this.pack();
    this.setSize(dimx, dimy);
    this.setLocation(posx, posy);
    this.show();
  }
Ejemplo n.º 23
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);
  }
Ejemplo n.º 24
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) {
      }
    }
  }
Ejemplo n.º 25
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);
  }