Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); if(shortcut != null) { d.width += (getFontMetrics(acceleratorFont) .stringWidth(shortcut) + 15); } return d; } //}}} //{{{ paint() method public void paint(Graphics g) { super.paint(g); if(shortcut != null) { g.setFont(acceleratorFont); g.setColor(getModel().isArmed() ? acceleratorSelectionForeground : acceleratorForeground); FontMetrics fm = g.getFontMetrics(); Insets insets = getInsets(); g.drawString(shortcut,getWidth() - (fm.stringWidth( shortcut) + insets.right + insets.left + 5), getFont().getSize() + (insets.top - (OperatingSystem.isMacOSLF() ? 0 : 1)) /* XXX magic number */); } } //}}} //{{{ Package-private members static Font acceleratorFont; static Color acceleratorForeground; static Color acceleratorSelectionForeground; //}}} //{{{ Private members //{{{ Instance variables private String shortcut; private String action; //}}} //{{{ getShortcut() method private String getShortcut() { if(action == null) return null; else { String shortcut1 = jEdit.getProperty(action + ".shortcut"); String shortcut2 = jEdit.getProperty(action + ".shortcut2"); if(shortcut1 == null || shortcut1.length() == 0) { if(shortcut2 == null || shortcut2.length() == 0) return null; else return shortcut2; } else { if(shortcut2 == null || shortcut2.length() == 0) return shortcut1; else return shortcut1 + " or " + shortcut2; } } }
Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); if(shortcut != null) { d.width += (getFontMetrics(EnhancedMenuItem.acceleratorFont) .stringWidth(shortcut) + 15); } return d; } //}}} //{{{ paint() method public void paint(Graphics g) { super.paint(g); if(shortcut != null) { g.setFont(EnhancedMenuItem.acceleratorFont); g.setColor(getModel().isArmed() ? EnhancedMenuItem.acceleratorSelectionForeground : EnhancedMenuItem.acceleratorForeground); FontMetrics fm = g.getFontMetrics(); Insets insets = getInsets(); g.drawString(shortcut,getWidth() - (fm.stringWidth( shortcut) + insets.right + insets.left + 5), getFont().getSize() + (insets.top - (OperatingSystem.isMacOSLF() ? 0 : 1)) /* XXX magic number */); } } //}}} //{{{ Private members //{{{ Instance variables private ActionContext context; private String shortcut; private String action; //}}} //{{{ getShortcut() method private String getShortcut() { if(action == null) return null; else { String shortcut1 = jEdit.getProperty(action + ".shortcut"); String shortcut2 = jEdit.getProperty(action + ".shortcut2"); if(shortcut1 == null || shortcut1.length() == 0) { if(shortcut2 == null || shortcut2.length() == 0) return null; else return shortcut2; } else { if(shortcut2 == null || shortcut2.length() == 0) return shortcut1; else return shortcut1 + " or " + shortcut2; } } }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/org/gjt/sp/jedit/menu/EnhancedMenuItem.java File path: /jEdit-4.2/src/org/gjt/sp/jedit/menu/EnhancedCheckBoxMenuItem.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
Dimension getPreferredSize()
1
Dimension getPreferredSize()
2
	{
2
	{
3
		Dimension d = super.getPreferredSize();
3
		Dimension d = super.getPreferredSize();
4
		if(shortcut != null)
4
		if(shortcut != null)
5
		{
5
		{
6
			d.width += (getFontMetrics(acceleratorFont)
6
			d.width += (getFontMetrics(EnhancedMenuItem.acceleratorFont)
7
				.stringWidth(shortcut) + 15);
7
				.stringWidth(shortcut) + 15);
8
		}
8
		}
9
		return d;
9
		return d;
10
	} //}}}
10
	} //}}}
11
	//{{{ paint() method
11
	//{{{ paint() method
12
	public void paint(Graphics g)
12
	public void paint(Graphics g)
13
	{
13
	{
14
		super.paint(g);
14
		super.paint(g);
15
		if(shortcut != null)
15
		if(shortcut != null)
16
		{
16
		{
17
			g.setFont(acceleratorFont);
17
			g.setFont(EnhancedMenuItem.acceleratorFont);
18
			g.setColor(getModel().isArmed() ?
18
			g.setColor(getModel().isArmed() ?
19
				acceleratorSelectionForeground :
19
				EnhancedMenuItem.acceleratorSelectionForeground :
20
				acceleratorForeground);
20
				EnhancedMenuItem.acceleratorForeground);
21
			FontMetrics fm = g.getFontMetrics();
21
			FontMetrics fm = g.getFontMetrics();
22
			Insets insets = getInsets();
22
			Insets insets = getInsets();
23
			g.drawString(shortcut,getWidth() - (fm.stringWidth(
23
			g.drawString(shortcut,getWidth() - (fm.stringWidth(
24
				shortcut) + insets.right + insets.left + 5),
24
				shortcut) + insets.right + insets.left + 5),
25
				getFont().getSize() + (insets.top - 
25
				getFont().getSize() + (insets.top - 
26
				(OperatingSystem.isMacOSLF() ? 0 : 1))
26
				(OperatingSystem.isMacOSLF() ? 0 : 1))
27
				/* XXX magic number */);
27
				/* XXX magic number */);
28
		}
28
		}
29
	} //}}}
29
	} //}}}
30
	//{{{ Package-private members
30
	//{{{ Private members
31
	static Font acceleratorFont;
32
	static Color acceleratorForeground;
33
	static Color acceleratorSelectionForeground;
34
	//}}}
35
	//{{{ Private members
36
	//{{{ Instance variables
31
	//{{{ Instance variables
32
	private ActionContext context;
37
	private String shortcut;
33
	private String shortcut;
38
	private String action;
34
	private String action;
39
	//}}}
35
	//}}}
40
	//{{{ getShortcut() method
36
	//{{{ getShortcut() method
41
	private String getShortcut()
37
	private String getShortcut()
42
	{
38
	{
43
		if(action == null)
39
		if(action == null)
44
			return null;
40
			return null;
45
		else
41
		else
46
		{
42
		{
47
			String shortcut1 = jEdit.getProperty(action + ".shortcut");
43
			String shortcut1 = jEdit.getProperty(action + ".shortcut");
48
			String shortcut2 = jEdit.getProperty(action + ".shortcut2");
44
			String shortcut2 = jEdit.getProperty(action + ".shortcut2");
49
			if(shortcut1 == null || shortcut1.length() == 0)
45
			if(shortcut1 == null || shortcut1.length() == 0)
50
			{
46
			{
51
				if(shortcut2 == null || shortcut2.length() == 0)
47
				if(shortcut2 == null || shortcut2.length() == 0)
52
					return null;
48
					return null;
53
				else
49
				else
54
					return shortcut2;
50
					return shortcut2;
55
			}
51
			}
56
			else
52
			else
57
			{
53
			{
58
				if(shortcut2 == null || shortcut2.length() == 0)
54
				if(shortcut2 == null || shortcut2.length() == 0)
59
					return shortcut1;
55
					return shortcut1;
60
				else
56
				else
61
					return shortcut1 + " or " + shortcut2;
57
					return shortcut1 + " or " + shortcut2;
62
			}
58
			}
63
		}
59
		}
64
	}
60
	}
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0