/** * Return <CODE>Vector</CODE> of <CODE>String</CODE>s describing the cursor location, if cursor * location display is enabled. * * @return The cursor location description as a Vector of Strings (an empty Vector if cursor * location display is disabled). */ public Vector getCursorStringVector() { if (cursor_string) { return (Vector) cursorStringVector.clone(); } else { return new Vector(); } }
/** Sets the call stack with the given vector of method names. */ public void setContents(Vector newMethodNames) { methodNames = (Vector) newMethodNames.clone(); callStackTable.revalidate(); Rectangle r = callStackTable.getCellRect(newMethodNames.size() - 1, 0, true); callStackTable.scrollRectToVisible(r); repaint(); }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
/** * Returns the component in the currently selected path which contains sourcePoint. * * @param source The component in whose coordinate space sourcePoint is given * @param sourcePoint The point which is being tested * @return The component in the currently selected path which contains sourcePoint (relative to * the source component's coordinate space. If sourcePoint is not inside a component on the * currently selected path, null is returned. */ public Component componentForPoint(Component source, Point sourcePoint) { int screenX, screenY; Point p = sourcePoint; int i, c, j, d; Component mc; Rectangle r2; int cWidth, cHeight; MenuElement menuElement; MenuElement subElements[]; Vector<MenuElement> tmp; int selectionSize; SwingUtilities.convertPointToScreen(p, source); screenX = p.x; screenY = p.y; tmp = (Vector<MenuElement>) selection.clone(); selectionSize = tmp.size(); for (i = selectionSize - 1; i >= 0; i--) { menuElement = (MenuElement) tmp.elementAt(i); subElements = menuElement.getSubElements(); for (j = 0, d = subElements.length; j < d; j++) { if (subElements[j] == null) continue; mc = subElements[j].getComponent(); if (!mc.isShowing()) continue; if (mc instanceof JComponent) { cWidth = mc.getWidth(); cHeight = mc.getHeight(); } else { r2 = mc.getBounds(); cWidth = r2.width; cHeight = r2.height; } p.x = screenX; p.y = screenY; SwingUtilities.convertPointFromScreen(p, mc); /** * Return the deepest component on the selection path in whose bounds the event's point * occurs */ if (p.x >= 0 && p.x < cWidth && p.y >= 0 && p.y < cHeight) { return mc; } } } return null; }
// clone this loop and all of its sub-components public Object clone() throws CloneNotSupportedException { Loop loop = new Loop(program); loop.type = type; loop.numReps = numReps; loop.numWarmups = numWarmups; loop.sync = sync; loop.sequenceName = sequenceName; loop.time = time; loop.timeUnits = timeUnits; loop.sequences = (Vector) sequences.clone(); for (int i = 0; i < components.size(); i++) { AbstractComponent component = (AbstractComponent) components.elementAt(i); loop.add((AbstractComponent) component.clone()); } return loop; }
/** * Return <CODE>Vector</CODE> of <CODE>String</CODE>s describing the cursor location, regardless * of whether cursor location display is enabled. * * @return The cursor location description as a Vector of Strings. */ public Vector getCursorStringVectorUnconditional() { return (Vector) cursorStringVector.clone(); }
/** * When a MenuElement receives an event from a MouseListener, it should never process the event * directly. Instead all MenuElements should call this method with the event. * * @param event a MouseEvent object */ public void processMouseEvent(MouseEvent event) { int screenX, screenY; Point p; int i, c, j, d; Component mc; Rectangle r2; int cWidth, cHeight; MenuElement menuElement; MenuElement subElements[]; MenuElement path[]; Vector<MenuElement> tmp; int selectionSize; p = event.getPoint(); Component source = event.getComponent(); if ((source != null) && !source.isShowing()) { // This can happen if a mouseReleased removes the // containing component -- bug 4146684 return; } int type = event.getID(); int modifiers = event.getModifiers(); // 4188027: drag enter/exit added in JDK 1.1.7A, JDK1.2 if ((type == MouseEvent.MOUSE_ENTERED || type == MouseEvent.MOUSE_EXITED) && ((modifiers & (InputEvent.BUTTON1_MASK | InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK)) != 0)) { return; } if (source != null) { SwingUtilities.convertPointToScreen(p, source); } screenX = p.x; screenY = p.y; tmp = (Vector<MenuElement>) selection.clone(); selectionSize = tmp.size(); boolean success = false; for (i = selectionSize - 1; i >= 0 && success == false; i--) { menuElement = (MenuElement) tmp.elementAt(i); subElements = menuElement.getSubElements(); path = null; for (j = 0, d = subElements.length; j < d && success == false; j++) { if (subElements[j] == null) continue; mc = subElements[j].getComponent(); if (!mc.isShowing()) continue; if (mc instanceof JComponent) { cWidth = mc.getWidth(); cHeight = mc.getHeight(); } else { r2 = mc.getBounds(); cWidth = r2.width; cHeight = r2.height; } p.x = screenX; p.y = screenY; SwingUtilities.convertPointFromScreen(p, mc); /** * Send the event to visible menu element if menu element currently in the selected path or * contains the event location */ if ((p.x >= 0 && p.x < cWidth && p.y >= 0 && p.y < cHeight)) { int k; if (path == null) { path = new MenuElement[i + 2]; for (k = 0; k <= i; k++) path[k] = (MenuElement) tmp.elementAt(k); } path[i + 1] = subElements[j]; MenuElement currentSelection[] = getSelectedPath(); // Enter/exit detection -- needs tuning... if (currentSelection[currentSelection.length - 1] != path[i + 1] && (currentSelection.length < 2 || currentSelection[currentSelection.length - 2] != path[i + 1])) { Component oldMC = currentSelection[currentSelection.length - 1].getComponent(); MouseEvent exitEvent = new MouseEvent( oldMC, MouseEvent.MOUSE_EXITED, event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); currentSelection[currentSelection.length - 1].processMouseEvent(exitEvent, path, this); MouseEvent enterEvent = new MouseEvent( mc, MouseEvent.MOUSE_ENTERED, event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); subElements[j].processMouseEvent(enterEvent, path, this); } MouseEvent mouseEvent = new MouseEvent( mc, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); subElements[j].processMouseEvent(mouseEvent, path, this); success = true; event.consume(); } } } }