bugged
stringlengths
6
599k
fixed
stringlengths
6
40.8M
__index_level_0__
int64
0
3.24M
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
8,530
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
8,531
protected void installKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
protected void installKeyboardActions() { // FIXME: Need to implement }
8,533
protected void installKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
super.installKeyboardActions(); super.installKeyboardActions(); protectedsuper.installKeyboardActions(); voidsuper.installKeyboardActions(); installKeyboardActions()super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); throwssuper.installKeyboardActions(); NotImplementedExceptionsuper.installKeyboardActions(); super.installKeyboardActions(); {super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); //super.installKeyboardActions(); FIXME:super.installKeyboardActions(); Needsuper.installKeyboardActions(); tosuper.installKeyboardActions(); implementsuper.installKeyboardActions(); super.installKeyboardActions(); }
8,534
protected void installListeners() { ((JMenu) menuItem).addMouseListener(mouseInputListener); ((JMenu) menuItem).addMouseMotionListener(mouseInputListener); ((JMenu) menuItem).addMenuListener(menuListener); ((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener); }
protected void installListeners() { ((JMenu) menuItem).addMouseListener(mouseInputListener); ((JMenu) menuItem).addMouseMotionListener(mouseInputListener); ((JMenu) menuItem).addMenuListener(menuListener); ((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener); }
8,535
protected void installListeners() { ((JMenu) menuItem).addMouseListener(mouseInputListener); ((JMenu) menuItem).addMouseMotionListener(mouseInputListener); ((JMenu) menuItem).addMenuListener(menuListener); ((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener); }
protected void installListeners() { ((JMenu) menuItem).addMouseListener(mouseInputListener); ((JMenu) menuItem).addMouseMotionListener(mouseInputListener); ((JMenu) menuItem).addMenuListener(menuListener); }
8,536
protected void setupPostTimer(JMenu menu) { // TODO: Implement this properly. }
Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); protectedTimer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); voidTimer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); setupPostTimer(JMenuTimer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); menu)Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); {Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); //Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); TODO:Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); ImplementTimer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); thisTimer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); properly.Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start(); }
8,537
protected void uninstallKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
protected void uninstallKeyboardActions() { // FIXME: Need to implement }
8,538
protected void uninstallKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
super.installKeyboardActions(); super.installKeyboardActions(); protectedsuper.installKeyboardActions(); voidsuper.installKeyboardActions(); uninstallKeyboardActions()super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); throwssuper.installKeyboardActions(); NotImplementedExceptionsuper.installKeyboardActions(); super.installKeyboardActions(); {super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); super.installKeyboardActions(); //super.installKeyboardActions(); FIXME:super.installKeyboardActions(); Needsuper.installKeyboardActions(); tosuper.installKeyboardActions(); implementsuper.installKeyboardActions(); super.installKeyboardActions(); }
8,539
protected void uninstallListeners() { ((JMenu) menuItem).removeMouseListener(mouseInputListener); ((JMenu) menuItem).removeMenuListener(menuListener); ((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener); }
protected void uninstallListeners() { super.uninstallListeners(); ((JMenu) menuItem).removeMenuListener(menuListener); ((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener); }
8,540
protected void uninstallListeners() { ((JMenu) menuItem).removeMouseListener(mouseInputListener); ((JMenu) menuItem).removeMenuListener(menuListener); ((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener); }
protected void uninstallListeners() { ((JMenu) menuItem).removeMouseListener(mouseInputListener); ((JMenu) menuItem).removeMenuListener(menuListener); }
8,541
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
public static String absolutize(String base, String href) throws MalformedURLException { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
8,542
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isURLScheme(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
8,543
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
8,544
private InputStream resolve(String url) throws IOException { try { return new URL(url).openStream(); } catch (MalformedURLException e) { return null; } }
static InputStream resolve(String url) throws IOException { try { return new URL(url).openStream(); } catch (MalformedURLException e) { return null; } }
8,545
public void menuDragMouseReleased(MenuDragMouseEvent e) { MenuElement[] path = e.getPath(); if (path[path.length - 1] instanceof JMenuItem) ((JMenuItem) path[path.length - 1]).doClick(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.clearSelectedPath(); }
public void menuDragMouseReleased(MenuDragMouseEvent e) { MenuElement[] path = e.getPath(); if (path[path.length - 1] instanceof JMenuItem) ((JMenuItem) path[path.length - 1]).doClick(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.clearSelectedPath(); }
8,548
public void mouseEntered(MouseEvent e) { Component source = (Component) e.getSource(); if (source.getParent() instanceof MenuElement) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(getPath()); manager.processMouseEvent(e); } }
public void mouseEntered(MouseEvent e) { Component source = (Component) e.getSource(); if (source.getParent() instanceof MenuElement) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(getPath()); manager.processMouseEvent(e); } }
8,549
public void mouseReleased(MouseEvent e) { Rectangle size = menuItem.getBounds(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0 && e.getY() < size.height) { manager.clearSelectedPath(); menuItem.doClick(); } else manager.processMouseEvent(e); }
public void mouseReleased(MouseEvent e) { Rectangle size = menuItem.getBounds(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0 && e.getY() < size.height) { manager.clearSelectedPath(); menuItem.doClick(); } else manager.processMouseEvent(e); }
8,550
public void mouseReleased(MouseEvent e) { Rectangle size = menuItem.getBounds(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0 && e.getY() < size.height) { manager.clearSelectedPath(); menuItem.doClick(); } else manager.processMouseEvent(e); }
public void mouseReleased(MouseEvent e) { Rectangle size = menuItem.getBounds(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0 && e.getY() < size.height) { manager.clearSelectedPath(); menuItem.doClick(); } else manager.processMouseEvent(e); }
8,551
public MenuElement[] getPath() { ArrayList path = new ArrayList(); // Path to menu should also include its popup menu. if (menuItem instanceof JMenu) path.add(((JMenu) menuItem).getPopupMenu()); Component c = menuItem; while (c instanceof MenuElement) { path.add(0, (MenuElement) c); if (c instanceof JPopupMenu) c = ((JPopupMenu) c).getInvoker(); else c = c.getParent(); } MenuElement[] pathArray = new MenuElement[path.size()]; path.toArray(pathArray); return pathArray; }
public MenuElement[] getPath() { ArrayList path = new ArrayList(); // Path to menu should also include its popup menu. if (menuItem instanceof JMenu) path.add(((JMenu) menuItem).getPopupMenu()); Component c = menuItem; while (c instanceof MenuElement) { path.add(0, (MenuElement) c); if (c instanceof JPopupMenu) c = ((JPopupMenu) c).getInvoker(); else c = c.getParent(); } MenuElement[] pathArray = new MenuElement[path.size()]; path.toArray(pathArray); return pathArray; }
8,552
public MenuElement[] getPath() { ArrayList path = new ArrayList(); // Path to menu should also include its popup menu. if (menuItem instanceof JMenu) path.add(((JMenu) menuItem).getPopupMenu()); Component c = menuItem; while (c instanceof MenuElement) { path.add(0, (MenuElement) c); if (c instanceof JPopupMenu) c = ((JPopupMenu) c).getInvoker(); else c = c.getParent(); } MenuElement[] pathArray = new MenuElement[path.size()]; path.toArray(pathArray); return pathArray; }
public MenuElement[] getPath() { ArrayList path = new ArrayList(); // Path to menu should also include its popup menu. if (menuItem instanceof JMenu) path.add(((JMenu) menuItem).getPopupMenu()); Component c = menuItem; while (c instanceof MenuElement) { path.add(0, (MenuElement) c); if (c instanceof JPopupMenu) c = ((JPopupMenu) c).getInvoker(); else c = c.getParent(); } MenuElement[] pathArray = new MenuElement[path.size()]; path.toArray(pathArray); return pathArray; }
8,553
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
8,554
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
8,555
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
8,556
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
8,557
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
8,558
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
8,559
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
8,560
private void paintAccelerator(Graphics g, JMenuItem menuItem, Rectangle acceleratorRect, String acceleratorText) { g.setFont(acceleratorFont); FontMetrics fm = g.getFontMetrics(acceleratorFont); if (menuItem.isEnabled()) g.setColor(acceleratorForeground); else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. g.setColor(Color.gray); BasicGraphicsUtils.drawString(g, acceleratorText, 0, acceleratorRect.x, acceleratorRect.y + fm.getAscent()); }
private void paintAccelerator(Graphics g, JMenuItem menuItem, Rectangle acceleratorRect, String acceleratorText) { g.setFont(acceleratorFont); FontMetrics fm = g.getFontMetrics(acceleratorFont); if (menuItem.isEnabled()) g.setColor(acceleratorForeground); else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. g.setColor(Color.gray); BasicGraphicsUtils.drawString(g, acceleratorText, 0, acceleratorRect.x, acceleratorRect.y + fm.getAscent()); }
8,561
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,562
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,563
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,564
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,565
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,566
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,567
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,568
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,569
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,570
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width - defaultTextIconGap; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
8,571
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
8,572
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
8,573
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
8,574
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
8,575
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
8,576
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
8,577
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); }
8,578
public void run() { try { synchronized (queueLock) { try { queueLock.wait(initialDelay); } catch (InterruptedException e) { // Ignored } if (!running) return; queueEvent(); if (repeats) while (running) { try { queueLock.wait(delay); } catch (InterruptedException e) { // Ignored } if (!running) break; queueEvent(); if (logTimers) System.out.println("javax.swing.Timer -> clocktick"); if ( ! repeats) break; } running = false; } } finally { // The timer is no longer running. running = false; } }
public void run() { try { synchronized (queueLock) { try { queueLock.wait(initialDelay); } catch (InterruptedException e) { // Ignored } if (!running) return; queueEvent(); if (repeats) while (running) { try { queueLock.wait(delay); } catch (InterruptedException e) { // Ignored } if (!running) break; queueEvent(); if (logTimers) System.out.println("javax.swing.Timer -> clocktick"); if ( ! repeats) break; } running = false; } } finally { // The timer is no longer running. running = false; } }
8,579
public void run() { try { synchronized (queueLock) { try { queueLock.wait(initialDelay); } catch (InterruptedException e) { // Ignored } if (!running) return; queueEvent(); if (repeats) while (running) { try { queueLock.wait(delay); } catch (InterruptedException e) { // Ignored } if (!running) break; queueEvent(); if (logTimers) System.out.println("javax.swing.Timer -> clocktick"); if ( ! repeats) break; } running = false; } } finally { // The timer is no longer running. running = false; } }
public void run() { try { synchronized (queueLock) { try { queueLock.wait(initialDelay); } catch (InterruptedException e) { // Ignored } if (!running) return; queueEvent(); if (repeats) while (running) { try { queueLock.wait(delay); } catch (InterruptedException e) { // Ignored } if (!running) break; queueEvent(); if (logTimers) System.out.println("javax.swing.Timer -> clocktick"); if ( ! repeats) break; } running = false; } } finally { // The timer is no longer running. running = false; } }
8,580
void queueEvent() { synchronized (queueLock) { queue++; if (queue == 1) SwingUtilities.invokeLater(drainer); } }
void queueEvent() { synchronized (queueLock) { queue++; if (queue == 1) SwingUtilities.invokeLater(drainer); } }
8,582
void queueEvent() { synchronized (queueLock) { queue++; if (queue == 1) SwingUtilities.invokeLater(drainer); } }
void queueEvent() { synchronized (queueLock) { queue++; if (queue == 1) SwingUtilities.invokeLater(drainer); }
8,583
public void start() { synchronized (queueLock) { if (waker != null) return; waker = new Waker(); waker.start(); } }
public void start() { synchronized (queueLock) { if (waker != null) return; waker = new Waker(); waker.start(); } }
8,584
public void stop() { synchronized (queueLock) { running = false; queue = 0; if (waker != null) queueLock.notifyAll(); waker = null; } }
public void stop() { synchronized (queueLock) { running = false; queue = 0; if (waker != null) queueLock.notifyAll(); waker = null; } }
8,586
public Area(Shape s) { }
public Area() { }
8,587
public void transform(AffineTransform at) { // XXX Implement. throw new Error("not implemented"); }
public void transform(AffineTransform at) { // XXX Implement. for (int i = 0; i < solids.size(); i++) ((Segment) solids.elementAt(i)).transformSegmentList(at); for (int i = 0; i < holes.size(); i++) ((Segment) holes.elementAt(i)).transformSegmentList(at); if ((at.getType() & AffineTransform.TYPE_FLIP) != 0) { setDirection(holes, false); setDirection(solids, true); }
8,589
public boolean contains(double x, double y) { // XXX Implement. throw new Error("not implemented"); }
public boolean contains(double x, double y) { // XXX Implement. int n = 0; for (int i = 0; i < solids.size(); i++) if (((Segment) solids.elementAt(i)).contains(x, y)) n++; for (int i = 0; i < holes.size(); i++) if (((Segment) holes.elementAt(i)).contains(x, y)) n--; return (n != 0); }
8,591
public boolean equals(Object obj) { if (obj instanceof UID) { UID uid = (UID)obj; if (this.unique == uid.unique && this.time == uid.time && this.count == uid.count) { return (true); } } return (false);}
public boolean equals(Object obj) { if (obj instanceof UID) { UID uid = (UID)obj; if (this.unique == uid.unique && this.time == uid.time && this.count == uid.count) { return (true); } } return (false);}
8,592
public int hashCode() { return (unique);}
public int hashCode() { return (unique);}
8,593
public int signum() { int top = words == null ? ival : words[ival-1]; if (top == 0 && words == null) return 0; return top < 0 ? -1 : 1; }
public int signum() { int top = words == null ? ival : words[ival-1]; if (top == 0 && words == null) return 0; return top < 0 ? -1 : 1; }
8,597
private void writeObject(ObjectOutputStream s) throws IOException, ClassNotFoundException { signum = signum(); magnitude = toByteArray(); s.defaultWriteObject(); }
private void writeObject(ObjectOutputStream s) throws IOException, ClassNotFoundException { signum = signum(); magnitude = signum == 0 ? new byte[0] : toByteArray(); s.defaultWriteObject(); }
8,598
public EmulatorAction(Session session, String name, KeyStroke ks, KeyMapper keyMap) { this(session,name); setKeyStroke(name, ks, keyMap); }
public EmulatorAction(Session session, String name) { this(session,name); setKeyStroke(name, ks, keyMap); }
8,599
public EmulatorAction(Session session, String name, KeyStroke ks, KeyMapper keyMap) { this(session,name); setKeyStroke(name, ks, keyMap); }
public EmulatorAction(Session session, String name, KeyStroke ks, KeyMapper keyMap) { this(session,name); setKeyStroke(name, ks, keyMap); }
8,600
protected void startPlugin() throws PluginException { try { final DeviceManager dm = DeviceUtils.getDeviceManager(); dm.addListener(this); final Collection devs = dm.getDevices(); for (Iterator i = devs.iterator(); i.hasNext();) { addListeners((Device) i.next()); } } catch (NameNotFoundException ex) { throw new PluginException(ex); } }
protected void startPlugin() throws PluginException { try { final DeviceManager dm = DeviceUtils.getDeviceManager(); dm.addListener(this); final Collection devs = new ArrayList(dm.getDevices()); for (Iterator i = devs.iterator(); i.hasNext();) { addListeners((Device) i.next()); } } catch (NameNotFoundException ex) { throw new PluginException(ex); } }
8,601
public Object action (SaxDocumentHandler handler, Attributes attrs) throws SAXException { // we only need to do these things for the first time we enter // a data node if (DataNodeLevel == 0) { // A little 'pre-handling' as href is a specialattribute // that will hold an (Href) object rather than string value Entity hrefObj = null; String hrefValue = getAttributesValueByName(attrs,"href"); if (hrefValue != null ) { // now we look up the href from the entity list gathered by // the parser and transfer relevant info to our Href object hrefObj = new Entity(); Hashtable hrefInfo = (Hashtable) UnParsedEntity.get(hrefValue);/*Log.errorln("Href Entity has following keys:");java.util.Set keys = hrefInfo.keySet();Iterator iter = keys.iterator();while (iter.hasNext()) { Log.errorln(" Key:"+iter.next().toString());}*/ if (UnParsedEntity.containsKey(hrefValue)) { hrefObj.setName((String) hrefInfo.get("name"));/* if (hrefInfo.containsKey("base")) hrefObj.setBase((String) hrefInfo.get("base"));*/ if (hrefInfo.containsKey("systemId")) hrefObj.setSystemId((String) hrefInfo.get("systemId")); if (hrefInfo.containsKey("publicId")) hrefObj.setPublicId((String) hrefInfo.get("publicId")); if (hrefInfo.containsKey("ndata")) hrefObj.setNdata((String) hrefInfo.get("ndata")); } else { // bizarre. It usually means that the unparsed entity handler // isnt working like it should Log.error("Error: UnParsedEntity list lacks entry for :"+hrefValue); Log.errorln(" ignoring request to read data."); } } // update the array dataCube with passed attributes CurrentArray.getDataCube().setAttributes(attrs); // Clean up. We override the string value of Href and set it as // the Href object , if we created it (yeh, sloppy). if (hrefObj != null) CurrentArray.getDataCube().setHref(hrefObj); // determine the size of the dataFormat (s) in our dataCube if (CurrentArray.hasFieldAxis()) { // if there is a field axis, then its set to the number of fields FieldAxis fieldAxis = CurrentArray.getFieldAxis(); MaxDataFormatIndex = (fieldAxis.getLength()-1); } else { // its homogeneous MaxDataFormatIndex = 0; } // reset to start of which dataformat type we currently are reading CurrentDataFormatIndex = 0; // reset to start of which IOCmd we currently are reading CurrentIOCmdIndex = 0; // reset the list of dataformats we are reading DataFormatList = CurrentArray.getDataFormatList(); NrofDataFormats = DataFormatList.length; IntRadix = new int [NrofDataFormats]; // CALCULATE CURRENTREADBYTES // set up some other global information bout the dataformats // that will help speed reading CurrentReadBytes = 0; for (int i=0; i < NrofDataFormats; i++) { CurrentReadBytes += DataFormatList[i].numOfBytes(); if (DataFormatList[i] instanceof IntegerDataFormat) { String type = ((IntegerDataFormat) DataFormatList[i]).getType(); if (type.equals(Constants.INTEGER_TYPE_DECIMAL)) IntRadix[i] = 10; else if (type.equals(Constants.INTEGER_TYPE_HEX)) IntRadix[i] = 16; else if (type.equals(Constants.INTEGER_TYPE_OCTAL)) IntRadix[i] = 8; else IntRadix[i] = 10; // default } else if (DataFormatList[i] instanceof BinaryIntegerDataFormat) { IntRadix[i] = 10; } } // DONT FORGET TO ADD IN THE SKIPCHAR bytes XMLDataIOStyle readObj = CurrentArray.getXMLDataIOStyle(); if (readObj instanceof FormattedXMLDataIOStyle) { Iterator citer = ((FormattedXMLDataIOStyle) readObj).getFormatCommands().iterator(); while (citer.hasNext()) { FormattedIOCmd currentIOCmd = (FormattedIOCmd) citer.next(); if (currentIOCmd instanceof SkipCharFormattedIOCmd) { Integer bytes_to_skip = ((SkipCharFormattedIOCmd) currentIOCmd).getCount(); CurrentReadBytes += bytes_to_skip.intValue(); } } } else if (readObj instanceof DelimitedXMLDataIOStyle || readObj instanceof TaggedXMLDataIOStyle ) { throw new SAXException("Cant parse delimited or tagged data from external file (yet)."); } if (CurrentReadBytes > MAXINPUTREADSIZE) { Log.errorln("This XDF file has single record that is too big (greater than "+MAXINPUTREADSIZE+" bytes in a record) to parse by this code"); System.exit(-1); } // now determine properread size CurrentInputReadSize = BASEINPUTREADSIZE * CurrentReadBytes; // make sure its not TOO big while (CurrentInputReadSize > MAXINPUTREADSIZE) { CurrentInputReadSize -= CurrentReadBytes; } } XMLDataIOStyle readObj = CurrentArray.getXMLDataIOStyle();// FastestAxis = (AxisInterface) CurrentArray.getAxes().get(0);// LastFastAxisCoordinate = 0; LastFieldAxisCoordinate = 0; if ( readObj instanceof TaggedXMLDataIOStyle) { TaggedLocatorObj = CurrentArray.createLocator(); } else { // A safety. We clear datablock when this is the first datanode we // have entered DATABLOCK is used in cases where we read in untagged data if (DataNodeLevel == 0) DATABLOCK = new StringBuffer (); } // tack in href data Entity href = CurrentArray.getDataCube().getHref(); if (href != null) // The first method is the 'old' way. // If you uncomment it be sure to uncomment line that looks like: // if (CurrentArray.getDataCube().getHref() != null) return; // in the end dataElementHandler // DATABLOCK.append(getHrefData(href, CurrentArray.getDataCube().getCompression())); loadHrefDataIntoCurrentArray(href, CurrentArray.getDataCube().getCompression()); // entered a datanode, raise the count // this (partially helps) declare we are now reading data, DataNodeLevel++; return readObj; }
public Object action (SaxDocumentHandler handler, Attributes attrs) throws SAXException { // we only need to do these things for the first time we enter // a data node if (DataNodeLevel == 0) { // A little 'pre-handling' as href is a specialattribute // that will hold an (Href) object rather than string value Entity hrefObj = null; String hrefValue = getAttributesValueByName(attrs,"href"); if (hrefValue != null ) { // now we look up the href from the entity list gathered by // the parser and transfer relevant info to our Href object hrefObj = new Entity(); Hashtable hrefInfo = (Hashtable) UnParsedEntity.get(hrefValue);/*Log.errorln("Href Entity has following keys:");java.util.Set keys = hrefInfo.keySet();Iterator iter = keys.iterator();while (iter.hasNext()) { Log.errorln(" Key:"+iter.next().toString());}*/ if (UnParsedEntity.containsKey(hrefValue)) { hrefObj.setName((String) hrefInfo.get("name"));/* if (hrefInfo.containsKey("base")) hrefObj.setBase((String) hrefInfo.get("base"));*/ if (hrefInfo.containsKey("systemId")) hrefObj.setSystemId((String) hrefInfo.get("systemId")); if (hrefInfo.containsKey("publicId")) hrefObj.setPublicId((String) hrefInfo.get("publicId")); if (hrefInfo.containsKey("ndata")) hrefObj.setNdata((String) hrefInfo.get("ndata")); } else { // bizarre. It usually means that the unparsed entity handler // isnt working like it should Log.error("Error: UnParsedEntity list lacks entry for :"+hrefValue); Log.errorln(" ignoring request to read data."); } } // update the array dataCube with passed attributes CurrentArray.getDataCube().setAttributes(attrs); // Clean up. We override the string value of Href and set it as // the Href object , if we created it (yeh, sloppy). if (hrefObj != null) CurrentArray.getDataCube().setHref(hrefObj); // determine the size of the dataFormat (s) in our dataCube if (CurrentArray.hasFieldAxis()) { // if there is a field axis, then its set to the number of fields FieldAxis fieldAxis = CurrentArray.getFieldAxis(); MaxDataFormatIndex = (fieldAxis.getLength()-1); } else { // its homogeneous MaxDataFormatIndex = 0; } // reset to start of which dataformat type we currently are reading CurrentDataFormatIndex = 0; // reset to start of which IOCmd we currently are reading CurrentIOCmdIndex = 0; // reset the list of dataformats we are reading DataFormatList = CurrentArray.getDataFormatList(); NrofDataFormats = DataFormatList.length; IntRadix = new int [NrofDataFormats]; // CALCULATE CURRENTREADBYTES // set up some other global information bout the dataformats // that will help speed reading CurrentReadBytes = 0; for (int i=0; i < NrofDataFormats; i++) { CurrentReadBytes += DataFormatList[i].numOfBytes(); if (DataFormatList[i] instanceof IntegerDataFormat) { String type = ((IntegerDataFormat) DataFormatList[i]).getType(); if (type.equals(Constants.INTEGER_TYPE_DECIMAL)) IntRadix[i] = 10; else if (type.equals(Constants.INTEGER_TYPE_HEX)) IntRadix[i] = 16; else if (type.equals(Constants.INTEGER_TYPE_OCTAL)) IntRadix[i] = 8; else IntRadix[i] = 10; // default } else if (DataFormatList[i] instanceof BinaryIntegerDataFormat) { IntRadix[i] = 10; } } // DONT FORGET TO ADD IN THE SKIPCHAR bytes XMLDataIOStyle readObj = CurrentArray.getXMLDataIOStyle(); if (readObj instanceof FormattedXMLDataIOStyle) { Iterator citer = ((FormattedXMLDataIOStyle) readObj).getFormatCommands().iterator(); while (citer.hasNext()) { FormattedIOCmd currentIOCmd = (FormattedIOCmd) citer.next(); if (currentIOCmd instanceof SkipCharFormattedIOCmd) { Integer bytes_to_skip = ((SkipCharFormattedIOCmd) currentIOCmd).getCount(); CurrentReadBytes += bytes_to_skip.intValue(); } } } else if (readObj instanceof DelimitedXMLDataIOStyle || readObj instanceof TaggedXMLDataIOStyle ) { throw new SAXException("Cant parse delimited or tagged data from external file (yet)."); } if (CurrentReadBytes > MAXINPUTREADSIZE) { Log.errorln("This XDF file has single record that is too big (greater than "+MAXINPUTREADSIZE+" bytes in a record) to parse by this code"); System.exit(-1); } // now determine properread size CurrentInputReadSize = BASEINPUTREADSIZE * CurrentReadBytes; // make sure its not TOO big while (CurrentInputReadSize > MAXINPUTREADSIZE) { CurrentInputReadSize -= CurrentReadBytes; } } XMLDataIOStyle readObj = CurrentArray.getXMLDataIOStyle();// FastestAxis = (AxisInterface) CurrentArray.getAxes().get(0);// LastFastAxisCoordinate = 0; LastFieldAxisCoordinate = 0; if ( readObj instanceof TaggedXMLDataIOStyle) { TaggedLocatorObj = CurrentArray.createLocator(); } else { // A safety. We clear datablock when this is the first datanode we // have entered DATABLOCK is used in cases where we read in untagged data if (DataNodeLevel == 0) DATABLOCK = new StringBuffer (); } // tack in href data Entity href = CurrentArray.getDataCube().getHref(); if (href != null) // The first method is the 'old' way. // If you uncomment it be sure to uncomment line that looks like: // if (CurrentArray.getDataCube().getHref() != null) return; // in the end dataElementHandler // DATABLOCK.append(getHrefData(href, CurrentArray.getDataCube().getCompression())); loadHrefDataIntoCurrentArray(href, CurrentArray.getDataCube().getCompression()); // entered a datanode, raise the count // this (partially helps) declare we are now reading data, DataNodeLevel++; return readObj; }
8,602
public Array appendArrayToArray ( Array arrayToAppendTo, Array arrayToAdd ) { if (arrayToAppendTo != null) { List origAxisList = arrayToAppendTo.getAxes(); List addAxisList = arrayToAdd.getAxes(); Hashtable correspondingAddAxis = new Hashtable(); Hashtable correspondingOrigAxis = new Hashtable(); // 1. determine the proper alignment of the axes between both arrays // Then cross-reference each in lookup Hashtables. Iterator iter = origAxisList.iterator(); while (iter.hasNext()) { AxisInterface origAxis = (AxisInterface) iter.next(); String align = origAxis.getAlign(); // search the list of the other array for a matching axis boolean gotAMatch = false; Iterator iter2 = addAxisList.iterator(); while (iter2.hasNext()) { AxisInterface addAxis = (AxisInterface) iter2.next(); String thisAlign = addAxis.getAlign(); if(thisAlign != null) { if(thisAlign.equals(align)) { correspondingAddAxis.put(origAxis.getAxisId(), addAxis); correspondingOrigAxis.put(addAxis.getAxisId(), origAxis); gotAMatch = true; break; } } else { Log.errorln("Cant align axes, axis missing defined align attribute. Aborting."); return arrayToAppendTo; } } // no match?? then alignments are mis-specified. if (!gotAMatch) { Log.errorln("Cant align axes, axis has align attribute that is mis-specified. Aborting."); return arrayToAppendTo; } } // 2. "Append" axis values to original axis. Because // there are 2 different ways to add in data we either // have a pre-existing axis value, in which case we dont // need to expand the existing axis, or there is no pre-existing // value so we tack it in. We need to figure out here if an // axis value already exists, and if it doesnt then we add it in. // Iterator iter3 = origAxisList.iterator(); while (iter3.hasNext()) { AxisInterface origAxis = (AxisInterface) iter3.next(); AxisInterface addAxis = (AxisInterface) correspondingAddAxis.get(origAxis.getAxisId()); if (addAxis instanceof Axis && origAxis instanceof Axis) { List valuesToAdd = ((Axis) addAxis).getAxisValues(); Iterator iter4 = valuesToAdd.iterator(); while (iter4.hasNext()) { Value value = (Value) iter4.next(); if (((Axis) origAxis).getIndexFromAxisValue(value) == -1) { ((Axis) origAxis).addAxisValue(value); } } } else if (addAxis instanceof FieldAxis && origAxis instanceof FieldAxis) { // both are fieldAxis Log.errorln("Dont know how to merge field Axis data. Aborting."); System.exit(-1); } else { // mixed class Axes?? (e.g. a fieldAxis id matches Axis id??!? Error!!) Log.errorln("Dont know how to merge data. Aborting."); System.exit(-1); } } // 3. Append data from one array to the other appropriately Locator origLocator = arrayToAppendTo.createLocator(); Locator addLocator = arrayToAdd.createLocator(); while (addLocator.hasNext()) { try { // retrieve the data Object data = arrayToAdd.getData(addLocator); // set up the origLocator List locatorAxisList = addLocator.getIterationOrder(); Iterator iter5 = locatorAxisList.iterator(); while (iter5.hasNext()) { Axis addAxis = (Axis) iter5.next(); Value thisAxisValue = addLocator.getAxisValue(addAxis); Axis thisAxis = (Axis) correspondingOrigAxis.get(addAxis.getAxisId()); try { origLocator.setAxisIndexByAxisValue(thisAxis, thisAxisValue); Log.debug(origLocator.getAxisIndex(thisAxis)+","); } catch (AxisLocationOutOfBoundsException e) { Log.errorln("Weird axis out of bounds error for append array."); } } // add in the data as appropriate. Log.debugln(") => ["+data.toString()+"]"); try { if (data instanceof Double) arrayToAppendTo.setData(origLocator, (Double) data); else if (data instanceof Integer) arrayToAppendTo.setData(origLocator, (Integer) data); else if (data instanceof String ) arrayToAppendTo.setData(origLocator, (String) data); else Log.errorln("Cant understand class of data !(Double|Integer|String). Ignoring append."); } catch (SetDataException e) { Log.errorln(e.getMessage()+". Ignoring append"); } } catch (NoDataException e) { // do nothing for NoDataValues?? Log.errorln(e.getMessage()); } addLocator.next(); // go to next location } } else Log.errorln("Cannot append to null array. Ignoring request."); return arrayToAppendTo; }
public Array appendArrayToArray ( Array arrayToAppendTo, Array arrayToAdd ) { if (arrayToAppendTo != null) { List origAxisList = arrayToAppendTo.getAxes(); List addAxisList = arrayToAdd.getAxes(); Hashtable correspondingAddAxis = new Hashtable(); Hashtable correspondingOrigAxis = new Hashtable(); // 1. determine the proper alignment of the axes between both arrays // Then cross-reference each in lookup Hashtables. Iterator iter = origAxisList.iterator(); while (iter.hasNext()) { AxisInterface origAxis = (AxisInterface) iter.next(); String align = origAxis.getAlign(); // search the list of the other array for a matching axis boolean gotAMatch = false; Iterator iter2 = addAxisList.iterator(); while (iter2.hasNext()) { AxisInterface addAxis = (AxisInterface) iter2.next(); String thisAlign = addAxis.getAlign(); if(thisAlign != null) { if(thisAlign.equals(align)) { correspondingAddAxis.put(origAxis.getAxisId(), addAxis); correspondingOrigAxis.put(addAxis.getAxisId(), origAxis); gotAMatch = true; break; } } else { Log.errorln("Cant align axes, axis missing defined align attribute. Aborting."); return arrayToAppendTo; } } // no match?? then alignments are mis-specified. if (!gotAMatch) { Log.errorln("Cant align axes, axis has align attribute that is mis-specified. Aborting."); return arrayToAppendTo; } } // 2. "Append" axis values to original axis. Because // there are 2 different ways to add in data we either // have a pre-existing axis value, in which case we dont // need to expand the existing axis, or there is no pre-existing // value so we tack it in. We need to figure out here if an // axis value already exists, and if it doesnt then we add it in. // Iterator iter3 = origAxisList.iterator(); while (iter3.hasNext()) { AxisInterface origAxis = (AxisInterface) iter3.next(); AxisInterface addAxis = (AxisInterface) correspondingAddAxis.get(origAxis.getAxisId()); if (addAxis instanceof Axis && origAxis instanceof Axis) { List valuesToAdd = ((Axis) addAxis).getAxisValues(); Iterator iter4 = valuesToAdd.iterator(); while (iter4.hasNext()) { Value value = (Value) iter4.next(); if (((Axis) origAxis).getIndexFromAxisValue(value) == -1) { ((Axis) origAxis).addAxisValue(value); } } } else if (addAxis instanceof FieldAxis && origAxis instanceof FieldAxis) { // both are fieldAxis Log.errorln("Dont know how to merge field Axis data. Aborting."); System.exit(-1); } else { // mixed class Axes?? (e.g. a fieldAxis id matches Axis id??!? Error!!) Log.errorln("Dont know how to merge data. Aborting."); System.exit(-1); } } // 3. Append data from one array to the other appropriately Locator origLocator = arrayToAppendTo.createLocator(); Locator addLocator = arrayToAdd.createLocator(); while (addLocator.hasNext()) { try { // retrieve the data Object data = arrayToAdd.getData(addLocator); // set up the origLocator List locatorAxisList = addLocator.getIterationOrder(); Iterator iter5 = locatorAxisList.iterator(); while (iter5.hasNext()) { Axis addAxis = (Axis) iter5.next(); Value thisAxisValue = addLocator.getAxisValue(addAxis); Axis thisAxis = (Axis) correspondingOrigAxis.get(addAxis.getAxisId()); try { origLocator.setAxisIndexByAxisValue(thisAxis, thisAxisValue); Log.debug(origLocator.getAxisIndex(thisAxis)+","); } catch (AxisLocationOutOfBoundsException e) { Log.errorln("Weird axis out of bounds error for append array."); } } // add in the data as appropriate. Log.debugln(") => ["+data.toString()+"]"); try { if (data instanceof Double) arrayToAppendTo.setData(origLocator, (Double) data); else if (data instanceof Integer) arrayToAppendTo.setData(origLocator, (Integer) data); else if (data instanceof String ) arrayToAppendTo.setData(origLocator, (String) data); else Log.errorln("Dont understand this class of data !(Double|Integer|String). Ignoring append."); } catch (SetDataException e) { Log.errorln(e.getMessage()+". Ignoring append"); } } catch (NoDataException e) { // do nothing for NoDataValues?? Log.errorln(e.getMessage()); } addLocator.next(); // go to next location } } else Log.errorln("Cannot append to null array. Ignoring request."); return arrayToAppendTo; }
8,603
protected void fireActionPerformed() { ActionEvent event = new ActionEvent(this, 0, getText()); ActionListener[] listeners = getActionListeners(); for (int index = 0; index < listeners.length; ++index) listeners[index].actionPerformed(event); }
protected void fireActionPerformed() { ActionEvent event = new ActionEvent(this, 0, actionCommand == null ? getText() : actionCommand); ActionListener[] listeners = getActionListeners(); for (int index = 0; index < listeners.length; ++index) listeners[index].actionPerformed(event); }
8,604
public static void main(String[] args) throws NoSuchAliasException, NameNotFoundException { ParsedArguments cmdLine = HELP_INFO.parse(args); final Shell shell = ShellUtils.getShellManager().getCurrentShell(); final AliasManager aliasMgr = shell.getAliasManager(); if (cmdLine.size() == 0) { for (Iterator i = aliasMgr.aliasIterator(); i.hasNext();) { final String alias = (String) i.next(); System.out.println(alias + ":\t" + aliasMgr.getAliasClassName(alias)); } } else if (PARAM_REMOVE.isSet(cmdLine)) { // remove an alias aliasMgr.remove(ARG_ALIAS.getValue(cmdLine)); } else { // add an alias aliasMgr.add(ARG_ALIAS.getValue(cmdLine), ARG_CLASS.getValue(cmdLine)); } }
public static void main(String[] args) throws NoSuchAliasException, NameNotFoundException { ParsedArguments cmdLine = HELP_INFO.parse(args); final Shell shell = ShellUtils.getShellManager().getCurrentShell(); final AliasManager aliasMgr = shell.getAliasManager(); if (cmdLine.size() == 0) { for (Iterator i = aliasMgr.aliasIterator(); i.hasNext();) { final String alias = (String) i.next(); System.out.println(alias + ":\t" + aliasMgr.getAliasClassName(alias)); } } else if (PARAM_REMOVE.isSet(cmdLine)) { // remove an alias aliasMgr.remove(ARG_ALIAS.getValue(cmdLine)); } else { // add an alias aliasMgr.add(ARG_ALIAS.getValue(cmdLine), ARG_CLASS.getValue(cmdLine)); } }
8,606
private DeviceToDriverMapper newMapperInstance(Class cls, ConfigurationElement element) throws InstantiationException, IllegalAccessException { try { final Constructor c = cls.getConstructor(new Class[] { ConfigurationElement.class }); try { return (DeviceToDriverMapper)c.newInstance(new Object[] { element }); } catch (InvocationTargetException ex1) { throw new InstantiationException(ex1.getTargetException()); } } catch (NoSuchMethodException ex) { return (DeviceToDriverMapper) cls.newInstance(); } }
private DeviceToDriverMapper newMapperInstance(Class cls, ConfigurationElement element) throws InstantiationException, IllegalAccessException { try { final Constructor c = cls.getConstructor(new Class[] { ConfigurationElement.class }); try { return (DeviceToDriverMapper)c.newInstance(new Object[] { element }); } catch (InvocationTargetException ex1) { final InstantiationException ie = new InstantiationException(); ie.initCause(ex1.getTargetException()); throw ie; } } catch (NoSuchMethodException ex) { return (DeviceToDriverMapper) cls.newInstance(); } }
8,607
public float getPreferredSpan(int axis) { if (view != null) return view.getPreferredSpan(axis); return Integer.MAX_VALUE; }
public float getPreferredSpan(int axis) { float span = 10; if (view != null) return view.getPreferredSpan(axis); return Integer.MAX_VALUE; }
8,609
public float getPreferredSpan(int axis) { if (view != null) return view.getPreferredSpan(axis); return Integer.MAX_VALUE; }
public float getPreferredSpan(int axis) { if (view != null) return view.getPreferredSpan(axis); return Integer.MAX_VALUE; }
8,610
public void paint(Graphics g, Shape s) { if (view != null) { Rectangle b = s.getBounds(); view.setSize(b.width, b.height); view.paint(g, s); } }
public void paint(Graphics g, Shape s) { if (view != null) { Rectangle b = s.getBounds(); view.setSize(b.width, b.height); view.paint(g, s); } }
8,612
public void setSize(float w, float h) { if (view != null) view.setSize(w, h); }
public synchronized void setSize(float w, float h) { if (view != null) view.setSize(w, h); }
8,614
public Dimension getMaximumSize(JComponent c) { // Sun's implementation returns Integer.MAX_VALUE here, so do we. return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); }
public Dimension getMaximumSize(JComponent c) { // Sun's implementation returns Integer.MAX_VALUE here, so do we. Dimension d = new Dimension(); Insets i = c.getInsets(); Document doc = textComponent.getDocument(); if (doc instanceof AbstractDocument) ((AbstractDocument) doc).readLock(); try { d.width = (int) Math.min((long) rootView.getMaximumSpan(View.X_AXIS) + i.left + i.right, Integer.MAX_VALUE); d.height = (int) Math.min((long) rootView.getMaximumSpan(View.Y_AXIS) + i.top + i.bottom, Integer.MAX_VALUE); } finally { if (doc instanceof AbstractDocument) ((AbstractDocument) doc).readUnlock(); } return d; }
8,616
public Dimension getMinimumSize(JComponent c) { Insets i = c.getInsets(); return new Dimension(i.left + i.right, i.top + i.bottom); }
public Dimension getMinimumSize(JComponent c) { Insets i = c.getInsets(); d.width += i.left + i.right; d.height += i.top + i.bottom; return d; }
8,617
public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException { // A comment in the spec of NavigationFilter.getNextVisualPositionFrom() // suggests that this method should be implemented by forwarding the call // the root view. return rootView.getNextVisualPositionFrom(pos, b, getVisibleEditorRect(), direction, biasRet); }
public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException { // A comment in the spec of NavigationFilter.getNextVisualPositionFrom() // suggests that this method should be implemented by forwarding the call // the root view. return rootView.getNextVisualPositionFrom(pos, b, getVisibleEditorRect(), direction, biasRet); }
8,618
public Dimension getPreferredSize(JComponent c) { Dimension d = c.getSize(); Insets i = c.getInsets(); if (d.width > (i.left + i.right) && d.height > (i.top + i.bottom)) { rootView.setSize(d.width - i.left - i.right, d.height - i.top - i.bottom); } float w = rootView.getPreferredSpan(View.X_AXIS); float h = rootView.getPreferredSpan(View.Y_AXIS); Dimension size = new Dimension((int) w + i.left + i.right, (int) h + i.top + i.bottom); return size; }
public Dimension getPreferredSize(JComponent c) { Dimension d = c.getSize(); Insets i = c.getInsets(); if (d.width > (i.left + i.right) && d.height > (i.top + i.bottom)) { rootView.setSize(d.width - i.left - i.right, d.height - i.top - i.bottom); } float w = rootView.getPreferredSpan(View.X_AXIS); float h = rootView.getPreferredSpan(View.Y_AXIS); Dimension size = new Dimension((int) w + i.left + i.right, (int) h + i.top + i.bottom); return size; }
8,620
protected Rectangle getVisibleEditorRect() { int width = textComponent.getWidth(); int height = textComponent.getHeight(); // Return null if the component has no valid size. if (width <= 0 || height <= 0) return null; Insets insets = textComponent.getInsets(); return new Rectangle(insets.left, insets.top, width - insets.left - insets.right, height - insets.top - insets.bottom); }
protected Rectangle getVisibleEditorRect() { int width = textComponent.getWidth(); int height = textComponent.getHeight(); // Return null if the component has no valid size. if (width <= 0 || height <= 0) return null; Insets insets = textComponent.getInsets(cachedInsets); return new Rectangle(insets.left, insets.top, width - insets.left - insets.right, height - insets.top - insets.bottom); }
8,621
protected void installDefaults() { String prefix = getPropertyPrefix(); // Install the standard properties. LookAndFeel.installColorsAndFont(textComponent, prefix + ".background", prefix + ".foreground", prefix + ".font"); LookAndFeel.installBorder(textComponent, prefix + ".border"); textComponent.setMargin(UIManager.getInsets(prefix + ".margin")); // Some additional text component only properties. Color color = textComponent.getCaretColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".caretForeground"); textComponent.setCaretColor(color); } // Fetch the colors for enabled/disabled text components. color = textComponent.getDisabledTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".inactiveBackground"); textComponent.setDisabledTextColor(color); } color = textComponent.getSelectedTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionForeground"); textComponent.setSelectedTextColor(color); } color = textComponent.getSelectionColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionBackground"); textComponent.setSelectionColor(color); } Insets margin = textComponent.getMargin(); if (margin == null || margin instanceof UIResource) { margin = UIManager.getInsets(prefix + ".margin"); textComponent.setMargin(margin); } Caret caret = textComponent.getCaret(); if (caret == null || caret instanceof UIResource) { caret = createCaret(); textComponent.setCaret(caret); caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate")); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null || highlighter instanceof UIResource) textComponent.setHighlighter(createHighlighter()); }
protected void installDefaults() { String prefix = getPropertyPrefix(); // Install the standard properties. LookAndFeel.installColorsAndFont(textComponent, prefix + ".background", prefix + ".foreground", prefix + ".font"); LookAndFeel.installBorder(textComponent, prefix + ".border"); // Some additional text component only properties. Color color = textComponent.getCaretColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".caretForeground"); textComponent.setCaretColor(color); } // Fetch the colors for enabled/disabled text components. color = textComponent.getDisabledTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".inactiveBackground"); textComponent.setDisabledTextColor(color); } color = textComponent.getSelectedTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionForeground"); textComponent.setSelectedTextColor(color); } color = textComponent.getSelectionColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionBackground"); textComponent.setSelectionColor(color); } Insets margin = textComponent.getMargin(); if (margin == null || margin instanceof UIResource) { margin = UIManager.getInsets(prefix + ".margin"); textComponent.setMargin(margin); } Caret caret = textComponent.getCaret(); if (caret == null || caret instanceof UIResource) { caret = createCaret(); textComponent.setCaret(caret); caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate")); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null || highlighter instanceof UIResource) textComponent.setHighlighter(createHighlighter()); }
8,622
protected void installDefaults() { String prefix = getPropertyPrefix(); // Install the standard properties. LookAndFeel.installColorsAndFont(textComponent, prefix + ".background", prefix + ".foreground", prefix + ".font"); LookAndFeel.installBorder(textComponent, prefix + ".border"); textComponent.setMargin(UIManager.getInsets(prefix + ".margin")); // Some additional text component only properties. Color color = textComponent.getCaretColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".caretForeground"); textComponent.setCaretColor(color); } // Fetch the colors for enabled/disabled text components. color = textComponent.getDisabledTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".inactiveBackground"); textComponent.setDisabledTextColor(color); } color = textComponent.getSelectedTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionForeground"); textComponent.setSelectedTextColor(color); } color = textComponent.getSelectionColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionBackground"); textComponent.setSelectionColor(color); } Insets margin = textComponent.getMargin(); if (margin == null || margin instanceof UIResource) { margin = UIManager.getInsets(prefix + ".margin"); textComponent.setMargin(margin); } Caret caret = textComponent.getCaret(); if (caret == null || caret instanceof UIResource) { caret = createCaret(); textComponent.setCaret(caret); caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate")); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null || highlighter instanceof UIResource) textComponent.setHighlighter(createHighlighter()); }
protected void installDefaults() { String prefix = getPropertyPrefix(); // Install the standard properties. LookAndFeel.installColorsAndFont(textComponent, prefix + ".background", prefix + ".foreground", prefix + ".font"); LookAndFeel.installBorder(textComponent, prefix + ".border"); textComponent.setMargin(UIManager.getInsets(prefix + ".margin")); // Some additional text component only properties. Color color = textComponent.getCaretColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".caretForeground"); textComponent.setCaretColor(color); } // Fetch the colors for enabled/disabled text components. color = textComponent.getDisabledTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".inactiveForeground"); textComponent.setDisabledTextColor(color); } color = textComponent.getSelectedTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionForeground"); textComponent.setSelectedTextColor(color); } color = textComponent.getSelectionColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionBackground"); textComponent.setSelectionColor(color); } Insets margin = textComponent.getMargin(); if (margin == null || margin instanceof UIResource) { margin = UIManager.getInsets(prefix + ".margin"); textComponent.setMargin(margin); } Caret caret = textComponent.getCaret(); if (caret == null || caret instanceof UIResource) { caret = createCaret(); textComponent.setCaret(caret); caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate")); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null || highlighter instanceof UIResource) textComponent.setHighlighter(createHighlighter()); }
8,623
protected void installDefaults() { String prefix = getPropertyPrefix(); // Install the standard properties. LookAndFeel.installColorsAndFont(textComponent, prefix + ".background", prefix + ".foreground", prefix + ".font"); LookAndFeel.installBorder(textComponent, prefix + ".border"); textComponent.setMargin(UIManager.getInsets(prefix + ".margin")); // Some additional text component only properties. Color color = textComponent.getCaretColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".caretForeground"); textComponent.setCaretColor(color); } // Fetch the colors for enabled/disabled text components. color = textComponent.getDisabledTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".inactiveBackground"); textComponent.setDisabledTextColor(color); } color = textComponent.getSelectedTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionForeground"); textComponent.setSelectedTextColor(color); } color = textComponent.getSelectionColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionBackground"); textComponent.setSelectionColor(color); } Insets margin = textComponent.getMargin(); if (margin == null || margin instanceof UIResource) { margin = UIManager.getInsets(prefix + ".margin"); textComponent.setMargin(margin); } Caret caret = textComponent.getCaret(); if (caret == null || caret instanceof UIResource) { caret = createCaret(); textComponent.setCaret(caret); caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate")); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null || highlighter instanceof UIResource) textComponent.setHighlighter(createHighlighter()); }
protected void installDefaults() { String prefix = getPropertyPrefix(); // Install the standard properties. LookAndFeel.installColorsAndFont(textComponent, prefix + ".background", prefix + ".foreground", prefix + ".font"); LookAndFeel.installBorder(textComponent, prefix + ".border"); textComponent.setMargin(UIManager.getInsets(prefix + ".margin")); // Some additional text component only properties. Color color = textComponent.getCaretColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".caretForeground"); textComponent.setCaretColor(color); } // Fetch the colors for enabled/disabled text components. color = textComponent.getDisabledTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".inactiveBackground"); textComponent.setDisabledTextColor(color); } color = textComponent.getSelectedTextColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionForeground"); textComponent.setSelectedTextColor(color); } color = textComponent.getSelectionColor(); if (color == null || color instanceof UIResource) { color = UIManager.getColor(prefix + ".selectionBackground"); textComponent.setSelectionColor(color); } Insets margin = textComponent.getMargin(); if (margin == null || margin instanceof UIResource) { margin = UIManager.getInsets(prefix + ".margin"); textComponent.setMargin(margin); } Caret caret = textComponent.getCaret(); if (caret == null || caret instanceof UIResource) { caret = createCaret(); textComponent.setCaret(caret); caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate")); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null || highlighter instanceof UIResource) textComponent.setHighlighter(createHighlighter()); }
8,624
protected void installListeners() { textComponent.addFocusListener(focuslistener); }
protected void installListeners() { if (SystemProperties.getProperty("gnu.swing.text.no-xlike-clipboard") == null) { if (focusListener == null) focusListener = new FocusHandler(); textComponent.addFocusListener(focusListener); } }
8,625
public void installUI(final JComponent c) { textComponent = (JTextComponent) c; installDefaults(); textComponent.addPropertyChangeListener(updateHandler); Document doc = textComponent.getDocument(); if (doc == null) { doc = getEditorKit(textComponent).createDefaultDocument(); textComponent.setDocument(doc); } else { doc.addDocumentListener(documentHandler); modelChanged(); } installListeners(); installKeyboardActions(); }
public void installUI(final JComponent c) { textComponent = (JTextComponent) c; installDefaults(); installFixedDefaults(); if (handler == null) handler = new Handler(); textComponent.addPropertyChangeListener(handler); Document doc = textComponent.getDocument(); if (doc == null) { doc = getEditorKit(textComponent).createDefaultDocument(); textComponent.setDocument(doc); } else { doc.addDocumentListener(documentHandler); modelChanged(); } installListeners(); installKeyboardActions(); }
8,626
public void installUI(final JComponent c) { textComponent = (JTextComponent) c; installDefaults(); textComponent.addPropertyChangeListener(updateHandler); Document doc = textComponent.getDocument(); if (doc == null) { doc = getEditorKit(textComponent).createDefaultDocument(); textComponent.setDocument(doc); } else { doc.addDocumentListener(documentHandler); modelChanged(); } installListeners(); installKeyboardActions(); }
public void installUI(final JComponent c) { textComponent = (JTextComponent) c; installDefaults(); textComponent.addPropertyChangeListener(updateHandler); Document doc = textComponent.getDocument(); if (doc == null) { doc = getEditorKit(textComponent).createDefaultDocument(); textComponent.setDocument(doc); } else { doc.addDocumentListener(handler); modelChanged(); } installListeners(); installKeyboardActions(); }
8,627
public final void paint(Graphics g, JComponent c) { try { Document doc = textComponent.getDocument(); if (doc instanceof AbstractDocument) { AbstractDocument aDoc = (AbstractDocument) doc; aDoc.readLock(); } paintSafely(g); } finally { Document doc = textComponent.getDocument(); if (doc instanceof AbstractDocument) { AbstractDocument aDoc = (AbstractDocument) doc; aDoc.readUnlock(); } } }
publicfinalvoidpaint(Graphicsg,JComponentc){try{Documentdoc=textComponent.getDocument();if(docinstanceofAbstractDocument){AbstractDocumentaDoc=(AbstractDocument)doc;aDoc.readLock();}paintSafely(g);}finally{Documentdoc=textComponent.getDocument();if(docinstanceofAbstractDocument){AbstractDocumentaDoc=(AbstractDocument)doc;aDoc.readUnlock();}}}
8,628
protected void paintSafely(Graphics g) { Caret caret = textComponent.getCaret(); Highlighter highlighter = textComponent.getHighlighter(); if (textComponent.isOpaque()) paintBackground(g); // Try painting with the highlighter without checking whether there // is a selection because a highlighter can be used to do more than // marking selected text. if (highlighter != null) { // Handle restoring of the color here to prevent // drawing problems when the Highlighter implementor // forgets to restore it. Color oldColor = g.getColor(); highlighter.paint(g); g.setColor(oldColor); } rootView.paint(g, getVisibleEditorRect()); if (caret != null && textComponent.hasFocus()) caret.paint(g); }
protectedvoidpaintSafely(Graphicsg){Caretcaret=textComponent.getCaret();Highlighterhighlighter=textComponent.getHighlighter();if(textComponent.isOpaque())paintBackground(g);//Trypaintingwiththehighlighterwithoutcheckingwhetherthere//isaselectionbecauseahighlightercanbeusedtodomorethan//markingselectedtext.if(highlighter!=null){//Handlerestoringofthecolorheretoprevent//drawingproblemswhentheHighlighterimplementor//forgetstorestoreit.ColoroldColor=g.getColor();highlighter.paint(g);g.setColor(oldColor);}rootView.paint(g,getVisibleEditorRect());if(caret!=null&&textComponent.hasFocus())caret.paint(g);}
8,629
protected void uninstallDefaults() { // Do nothing here. }
if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); protectedif (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); voidif (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); uninstallDefaults()if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); {if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); //if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); Doif (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); nothingif (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); here.if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); if (textComponent.getCaretColor() instanceof UIResource) textComponent.setCaretColor(null); if (textComponent.getSelectionColor() instanceof UIResource) textComponent.setSelectionColor(null); if (textComponent.getDisabledTextColor() instanceof UIResource) textComponent.setDisabledTextColor(null); if (textComponent.getSelectedTextColor() instanceof UIResource) textComponent.setSelectedTextColor(null); LookAndFeel.uninstallBorder(textComponent); if (textComponent.getMargin() instanceof UIResource) textComponent.setMargin(null); }
8,630
protected void uninstallListeners() { textComponent.removeFocusListener(focuslistener); textComponent.getDocument().removeDocumentListener(documentHandler); }
protected void uninstallListeners() { textComponent.removeFocusListener(focuslistener); textComponent.getDocument().removeDocumentListener(documentHandler); }
8,631
public void uninstallUI(final JComponent component) { super.uninstallUI(component); rootView.setView(null); uninstallDefaults(); uninstallListeners(); uninstallKeyboardActions(); textComponent = null; }
public void uninstallUI(final JComponent component) { textComponent.removePropertyChangeListener(handler); textComponent.getDocument().removeDocumentListener(handler); rootView.setView(null); uninstallDefaults(); uninstallListeners(); uninstallKeyboardActions(); textComponent = null; }
8,632
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { doValuePrint (outputstream, specialValue, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
8,634
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { doValuePrint (outputstream, specialValue, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
8,635
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { doValuePrint (outputstream, specialValue, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
8,636
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { doValuePrint (outputstream, specialValue, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
8,637
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { doValuePrint (outputstream, specialValue, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
8,638
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
public void toXMLOutputStream (OutputStream outputstream, String indent) throws java.io.IOException { if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired // no need to have repeatable set to 'yes' would just waste space even if we used this functionality. writeOut(outputstream, "<valueList delimiter=\""+valueListDelimiter+"\" repeatable=\"no\""); if (valueListNoData != null) writeOut(outputstream, " noDataValue=\""+valueListNoData+"\""); if (valueListInfinite != null) writeOut(outputstream, " infiniteValue=\""+valueListInfinite+"\""); if (valueListInfiniteNegative != null) writeOut(outputstream, " infiniteNegaiveValue=\""+valueListInfiniteNegative+"\""); if (valueListNotANumber != null) writeOut(outputstream, " notANumberValue=\""+valueListNotANumber+"\""); if (valueListUnderflow != null) writeOut(outputstream, " underflowValue=\""+valueListUnderflow+"\""); if (valueListOverflow != null) writeOut(outputstream, " overflowValue=\""+valueListOverflow+"\""); writeOut(outputstream, ">"); Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = (Value) iter.next(); String specialValue = thisValue.getSpecial(); if(specialValue != null) { if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE)) { writeOut(outputstream, valueListInfinite); } else if(specialValue.equals(Constants.VALUE_SPECIAL_INFINITE_NEGATIVE)) { writeOut(outputstream, valueListInfiniteNegative); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NODATA)) { writeOut(outputstream, valueListNoData); } else if(specialValue.equals(Constants.VALUE_SPECIAL_NOTANUMBER)) { writeOut(outputstream, valueListNotANumber); } else if(specialValue.equals(Constants.VALUE_SPECIAL_UNDERFLOW)) { writeOut(outputstream, valueListUnderflow); } else if(specialValue.equals(Constants.VALUE_SPECIAL_OVERFLOW)) { writeOut(outputstream, valueListOverflow); } else { Log.errorln("Error: valueList doesnt have "+specialValue+" defined but value does. Ignoring value."); } } else { writeOut(outputstream, thisValue.getValue()); } if (iter.hasNext()) writeOut(outputstream, valueListDelimiter); } writeOut(outputstream, "</valueList>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); }
8,639
public boolean match(Certificate certificate) { if (!(certificate instanceof X509Certificate)) return false; X509Certificate cert = (X509Certificate) certificate; if (this.cert != null) { try { byte[] e1 = this.cert.getEncoded(); byte[] e2 = cert.getEncoded(); if (!Arrays.equals(e1, e2)) return false; } catch (CertificateEncodingException cee) { return false; } } if (serialNo != null) { if (!serialNo.equals(cert.getSerialNumber())) return false; } if (certValid != null) { try { cert.checkValidity(certValid); } catch (CertificateException ce) { return false; } } if (issuer != null) { if (!issuer.equals(cert.getIssuerX500Principal())) return false; } if (subject != null) { if (!subject.equals(cert.getSubjectX500Principal())) return false; } if (sigId != null) { if (!sigId.equals(cert.getSigAlgOID())) return false; } if (subjectKeyId != null) { byte[] b = cert.getExtensionValue(SUBJECT_KEY_ID); if (!Arrays.equals(b, subjectKeyId)) return false; } if (authKeyId != null) { byte[] b = cert.getExtensionValue(AUTH_KEY_ID); if (!Arrays.equals(b, authKeyId)) return false; } if (keyUsage != null) { boolean[] b = cert.getKeyUsage(); if (!Arrays.equals(b, keyUsage)) return false; } if (basicConstraints >= 0) { if (cert.getBasicConstraints() != basicConstraints) return false; } if (keyPurposeSet != null) { List kp = null; try { kp = cert.getExtendedKeyUsage(); } catch (CertificateParsingException cpe) { return false; } if (kp == null) return false; for (Iterator it = keyPurposeSet.iterator(); it.hasNext(); ) { if (!kp.contains(it.next())) return false; } } if (altNames != null) { Collection an = null; try { an = cert.getSubjectAlternativeNames(); } catch (CertificateParsingException cpe) { return false; } if (an == null) return false; int match = 0; for (Iterator it = altNames.iterator(); it.hasNext(); ) { List l = (List) it.next(); Integer id = (Integer) l.get(0); String s = null; byte[] b = null; if (l.get(1) instanceof String) s = (String) l.get(1); else if (l.get(1) instanceof byte[]) b = (byte[]) l.get(1); else return false; for (Iterator it2 = an.iterator(); it2.hasNext(); ) { Object o = it2.next(); if (!(o instanceof List)) continue; List l2 = (List) o; if (l2.size() != 2) continue; if (!id.equals(l2.get(0))) continue; if (s != null && (l2.get(1) instanceof String) && s.equals(l2.get(1))) match++; else if (b != null && (l2.get(1) instanceof byte[]) && Arrays.equals(b, (byte[]) l2.get(1))) match++; } if (match == 0 || (matchAllNames && match != altNames.size())) return false; } } if (nameConstraints != null) { byte[] nc = cert.getExtensionValue(NAME_CONSTRAINTS_ID); if (!Arrays.equals(nameConstraints, nc)) return false; } // FIXME check policies. // FIXME check path-to-names. return true; }
public boolean match(Certificate certificate) { if (!(certificate instanceof X509Certificate)) return false; X509Certificate cert = (X509Certificate) certificate; if (this.cert != null) { try { byte[] e1 = this.cert.getEncoded(); byte[] e2 = cert.getEncoded(); if (!Arrays.equals(e1, e2)) return false; } catch (CertificateEncodingException cee) { return false; } } if (serialNo != null) { if (!serialNo.equals(cert.getSerialNumber())) return false; } if (certValid != null) { try { cert.checkValidity(certValid); } catch (CertificateException ce) { return false; } } if (issuer != null) { if (!issuer.equals(cert.getIssuerX500Principal())) return false; } if (subject != null) { if (!subject.equals(cert.getSubjectX500Principal())) return false; } if (sigId != null) { if (!sigId.toString().equals(cert.getSigAlgOID())) return false; } if (subjectKeyId != null) { byte[] b = cert.getExtensionValue(SUBJECT_KEY_ID); if (!Arrays.equals(b, subjectKeyId)) return false; } if (authKeyId != null) { byte[] b = cert.getExtensionValue(AUTH_KEY_ID); if (!Arrays.equals(b, authKeyId)) return false; } if (keyUsage != null) { boolean[] b = cert.getKeyUsage(); if (!Arrays.equals(b, keyUsage)) return false; } if (basicConstraints >= 0) { if (cert.getBasicConstraints() != basicConstraints) return false; } if (keyPurposeSet != null) { List kp = null; try { kp = cert.getExtendedKeyUsage(); } catch (CertificateParsingException cpe) { return false; } if (kp == null) return false; for (Iterator it = keyPurposeSet.iterator(); it.hasNext(); ) { if (!kp.contains(it.next())) return false; } } if (altNames != null) { Collection an = null; try { an = cert.getSubjectAlternativeNames(); } catch (CertificateParsingException cpe) { return false; } if (an == null) return false; int match = 0; for (Iterator it = altNames.iterator(); it.hasNext(); ) { List l = (List) it.next(); Integer id = (Integer) l.get(0); String s = null; byte[] b = null; if (l.get(1) instanceof String) s = (String) l.get(1); else if (l.get(1) instanceof byte[]) b = (byte[]) l.get(1); else return false; for (Iterator it2 = an.iterator(); it2.hasNext(); ) { Object o = it2.next(); if (!(o instanceof List)) continue; List l2 = (List) o; if (l2.size() != 2) continue; if (!id.equals(l2.get(0))) continue; if (s != null && (l2.get(1) instanceof String) && s.equals(l2.get(1))) match++; else if (b != null && (l2.get(1) instanceof byte[]) && Arrays.equals(b, (byte[]) l2.get(1))) match++; } if (match == 0 || (matchAllNames && match != altNames.size())) return false; } } if (nameConstraints != null) { byte[] nc = cert.getExtensionValue(NAME_CONSTRAINTS_ID); if (!Arrays.equals(nameConstraints, nc)) return false; } // FIXME check policies. // FIXME check path-to-names. return true; }
8,640
protected PropertyChangeListener createActionPropertyChangeListener(Action a) { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); if (e.getPropertyName().equals(AbstractAction.ENABLED_PROPERTY)) setEnabled(act.isEnabled()); else if (e.getPropertyName().equals(Action.NAME)) setText((String)(act.getValue(Action.NAME))); else if (e.getPropertyName().equals(Action.SMALL_ICON)) setIcon((Icon)(act.getValue(Action.SMALL_ICON))); else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION)) setToolTipText((String)(act.getValue(Action.SHORT_DESCRIPTION))); else if (e.getPropertyName().equals(Action.MNEMONIC_KEY)) if (act.getValue(Action.MNEMONIC_KEY) != null) setMnemonic(((Integer)(act.getValue(Action.MNEMONIC_KEY))).intValue()); else if (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY)) setActionCommand((String)(act.getValue(Action.ACTION_COMMAND_KEY))); } }; }
protected PropertyChangeListener createActionPropertyChangeListener(Action a) { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); if (e.getPropertyName().equals(AbstractAction.ENABLED_PROPERTY)) setEnabled(act.isEnabled()); else if (e.getPropertyName().equals(Action.NAME)) setText((String)(act.getValue(Action.NAME))); else if (e.getPropertyName().equals(Action.SMALL_ICON)) setIcon((Icon)(act.getValue(Action.SMALL_ICON))); else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION)) setToolTipText((String)(act.getValue(Action.SHORT_DESCRIPTION))); else if (e.getPropertyName().equals(Action.MNEMONIC_KEY)) if (act.getValue(Action.MNEMONIC_KEY) != null) setMnemonic(((Integer)(act.getValue(Action.MNEMONIC_KEY))).intValue()); else if (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY)) setActionCommand((String)(act.getValue(Action.ACTION_COMMAND_KEY))); } }; }
8,641
public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); if (e.getPropertyName().equals(AbstractAction.ENABLED_PROPERTY)) setEnabled(act.isEnabled()); else if (e.getPropertyName().equals(Action.NAME)) setText((String)(act.getValue(Action.NAME))); else if (e.getPropertyName().equals(Action.SMALL_ICON)) setIcon((Icon)(act.getValue(Action.SMALL_ICON))); else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION)) setToolTipText((String)(act.getValue(Action.SHORT_DESCRIPTION))); else if (e.getPropertyName().equals(Action.MNEMONIC_KEY)) if (act.getValue(Action.MNEMONIC_KEY) != null) setMnemonic(((Integer)(act.getValue(Action.MNEMONIC_KEY))).intValue()); else if (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY)) setActionCommand((String)(act.getValue(Action.ACTION_COMMAND_KEY))); }
public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); if (e.getPropertyName().equals(AbstractAction.ENABLED_PROPERTY)) setEnabled(act.isEnabled()); else if (e.getPropertyName().equals(Action.NAME)) setText((String)(act.getValue(Action.NAME))); else if (e.getPropertyName().equals(Action.SMALL_ICON)) setIcon((Icon)(act.getValue(Action.SMALL_ICON))); else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION)) setToolTipText((String)(act.getValue(Action.SHORT_DESCRIPTION))); else if (e.getPropertyName().equals(Action.MNEMONIC_KEY)) if (act.getValue(Action.MNEMONIC_KEY) != null) setMnemonic(((Integer)(act.getValue(Action.MNEMONIC_KEY))).intValue()); else if (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY)) setActionCommand((String)(act.getValue(Action.ACTION_COMMAND_KEY))); }
8,642
public void fireActionPerformed(ActionEvent e) { e.setSource(this); ActionListener[] listeners = getActionListeners(); for (int i = 0; i < listeners.length; i++) listeners[i].actionPerformed(e); }
protected void fireActionPerformed(ActionEvent e) { e.setSource(this); ActionListener[] listeners = getActionListeners(); for (int i = 0; i < listeners.length; i++) listeners[i].actionPerformed(e); }
8,643
public void fireItemStateChanged(ItemEvent e) { e.setSource(this); ItemListener[] listeners = getItemListeners(); for (int i = 0; i < listeners.length; i++) listeners[i].itemStateChanged(e); }
protected void fireItemStateChanged(ItemEvent e) { e.setSource(this); ItemListener[] listeners = getItemListeners(); for (int i = 0; i < listeners.length; i++) listeners[i].itemStateChanged(e); }
8,644
public void fireStateChanged() { ChangeListener[] listeners = getChangeListeners(); for (int i = 0; i < listeners.length; i++) listeners[i].stateChanged(changeEvent); }
protected void fireStateChanged() { ChangeListener[] listeners = getChangeListeners(); for (int i = 0; i < listeners.length; i++) listeners[i].stateChanged(changeEvent); }
8,645
protected String paramString() { return "AbstractButton"; }
protected String paramString() { StringBuffer sb = new StringBuffer(); sb.append(super.paramString()); sb.append(",defaultIcon="); if (getIcon() != null) sb.append(getIcon()); sb.append(",disabledIcon="); if (getDisabledIcon() != null) sb.append(getDisabledIcon()); sb.append(",disabledSelectedIcon="); if (getDisabledSelectedIcon() != null) sb.append(getDisabledSelectedIcon()); sb.append(",margin="); if (getMargin() != null) sb.append(getMargin()); sb.append(",paintBorder=").append(isBorderPainted()); sb.append(",paintFocus=").append(isFocusPainted()); sb.append(",pressedIcon="); if (getPressedIcon() != null) sb.append(getPressedIcon()); sb.append(",rolloverEnabled=").append(isRolloverEnabled()); sb.append(",rolloverIcon="); if (getRolloverIcon() != null) sb.append(getRolloverIcon()); sb.append(",rolloverSelected="); if (getRolloverSelectedIcon() != null) sb.append(getRolloverSelectedIcon()); sb.append(",selectedIcon="); if (getSelectedIcon() != null) sb.append(getSelectedIcon()); sb.append(",text="); if (getText() != null) sb.append(getText()); return sb.toString(); }
8,646