class HorizontalPanel extends JPanel { private Box subPanel = Box.createHorizontalBox(); private float verticalAlign; private int hgap; public HorizontalPanel() { this(5, CENTER_ALIGNMENT); } public HorizontalPanel(Color bk) { this(); subPanel.setBackground(bk); this.setBackground(bk); } public HorizontalPanel(int hgap, float verticalAlign) { super(new BorderLayout()); add(subPanel, BorderLayout.WEST); this.hgap = hgap; this.verticalAlign = verticalAlign; } /* * (non-Javadoc) * * @see java.awt.Container#add(java.awt.Component) */ public Component add(Component c) { // This won't work right if we remove components. But we don't, so I'm // not going to worry about it right now. if (hgap > 0 && subPanel.getComponentCount() > 0) { subPanel.add(Box.createHorizontalStrut(hgap)); } if (c instanceof JComponent) { ((JComponent) c).setAlignmentY(verticalAlign); } return subPanel.add(c); }
class VerticalPanel extends JPanel { private Box subPanel = Box.createVerticalBox(); private float horizontalAlign; private int vgap; public VerticalPanel() { this(5, LEFT_ALIGNMENT); } public VerticalPanel(Color bkg) { this(); subPanel.setBackground(bkg); this.setBackground(bkg); } public VerticalPanel(int vgap, float horizontalAlign) { super(new BorderLayout()); add(subPanel, BorderLayout.NORTH); this.vgap = vgap; this.horizontalAlign = horizontalAlign; } /* * (non-Javadoc) * * @see java.awt.Container#add(java.awt.Component) */ public Component add(Component c) { // This won't work right if we remove components. But we don't, so I'm // not going to worry about it right now. if (vgap > 0 && subPanel.getComponentCount() > 0) { subPanel.add(Box.createVerticalStrut(vgap)); } if (c instanceof JComponent) { ((JComponent) c).setAlignmentX(horizontalAlign); } return subPanel.add(c); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/HorizontalPanel.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/VerticalPanel.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
class HorizontalPanel extends JPanel {
1
class VerticalPanel extends JPanel {
2
	private Box subPanel = Box.createHorizontalBox();
2
	private Box subPanel = Box.createVerticalBox();
3
	private float verticalAlign;
3
	private float horizontalAlign;
4
	private int hgap;
4
	private int vgap;
5
	public HorizontalPanel() {
5
	public VerticalPanel() {
6
		this(5, CENTER_ALIGNMENT);
6
		this(5, LEFT_ALIGNMENT);
7
	}
7
	}
8
	public HorizontalPanel(Color bk) {
8
    public VerticalPanel(Color bkg) {
9
		this();
9
        this();
10
		subPanel.setBackground(bk);
10
        subPanel.setBackground(bkg);
11
		this.setBackground(bk);
11
        this.setBackground(bkg);
12
	}
13
	
12
    }
13
    
14
	public HorizontalPanel(int hgap, float verticalAlign) {
14
	public VerticalPanel(int vgap, float horizontalAlign) {
15
		super(new BorderLayout());
15
		super(new BorderLayout());
16
		add(subPanel, BorderLayout.WEST);
16
		add(subPanel, BorderLayout.NORTH);
17
		this.hgap = hgap;
17
		this.vgap = vgap;
18
		this.verticalAlign = verticalAlign;
18
		this.horizontalAlign = horizontalAlign;
19
	}
19
	}
20
	/*
20
	/*
21
	 * (non-Javadoc)
21
	 * (non-Javadoc)
22
	 * 
22
	 * 
23
	 * @see java.awt.Container#add(java.awt.Component)
23
	 * @see java.awt.Container#add(java.awt.Component)
24
	 */
24
	 */
25
	public Component add(Component c) {
25
	public Component add(Component c) {
26
		// This won't work right if we remove components. But we don't, so I'm
26
		// This won't work right if we remove components. But we don't, so I'm
27
		// not going to worry about it right now.
27
		// not going to worry about it right now.
28
		if (hgap > 0 && subPanel.getComponentCount() > 0) {
28
		if (vgap > 0 && subPanel.getComponentCount() > 0) {
29
			subPanel.add(Box.createHorizontalStrut(hgap));
29
			subPanel.add(Box.createVerticalStrut(vgap));
30
		}
30
		}
31
		if (c instanceof JComponent) {
31
		if (c instanceof JComponent) {
32
			((JComponent) c).setAlignmentY(verticalAlign);
32
			((JComponent) c).setAlignmentX(horizontalAlign);
33
		}
33
		}
34
		return subPanel.add(c);
34
		return subPanel.add(c);
35
	}
35
	}
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