项目:cn1
文件:SpringLayoutTest.java
public void testAddLayoutComponent() throws Exception {
Constraints constraints = new Constraints(Spring.constant(1),Spring.constant(2),Spring.constant(3),Spring.constant(4));
layout.addLayoutComponent(null,constraints);
Constraints componentCnstraints = layout.getConstraints(null);
assertNotNull(componentCnstraints);
assertSame(componentCnstraints,constraints);
layout.addLayoutComponent(button,null);
componentCnstraints = layout.getConstraints(button);
assertNotNull(componentCnstraints);
assertEquals(componentCnstraints.getX().getValue(),0);
assertEquals(componentCnstraints.getY().getValue(),0);
assertEquals(componentCnstraints.getWidth().getValue(),button.getPreferredSize().width);
assertEquals(componentCnstraints.getHeight().getValue(),button.getPreferredSize().height);
layout.addLayoutComponent(button,constraints);
componentCnstraints = layout.getConstraints(button);
assertSame(componentCnstraints,constraints);
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_SetHeight() throws Exception {
layout.getConstraints(container).setHeight(Spring.constant(5));
layout.getConstraints(button).setHeight(Spring.constant(6));
layout.getConstraints(button).setHeight(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setHeight(Spring.constant(8));
constraints.setY(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,Spring.constant(40));
layout.getConstraints(panel).setHeight(Spring.constant(6));
constraints.setY(Spring.constant(20));
layout.getConstraints(innerButton).setHeight(Spring.constant(15));
container.setSize(200,300);
layout.layoutContainer(container);
assertEquals(300,container.getHeight());
assertEquals(8,button.getHeight());
assertEquals(8,textField.getHeight());
assertEquals(6,panel.getHeight());
assertEquals(0,innerButton.getHeight());
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_SetWidth() throws Exception {
layout.getConstraints(container).setWidth(Spring.constant(5));
layout.getConstraints(button).setWidth(Spring.constant(6));
layout.getConstraints(button).setWidth(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setWidth(Spring.constant(8));
constraints.setX(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,Spring.constant(40));
layout.getConstraints(panel).setWidth(Spring.constant(6));
constraints.setX(Spring.constant(20));
layout.getConstraints(innerButton).setWidth(Spring.constant(15));
container.setSize(200,300);
layout.layoutContainer(container);
assertEquals(200,container.getWidth());
assertEquals(8,button.getWidth());
assertEquals(20,textField.getWidth());
assertEquals(6,panel.getWidth());
assertEquals(0,innerButton.getWidth());
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_SetX() throws Exception {
layout.getConstraints(container).setX(Spring.constant(5));
layout.getConstraints(button).setX(Spring.constant(6));
layout.getConstraints(button).setX(Spring.constant(7));
Constraints constraints = layout.getConstraints(textField);
constraints.setX(Spring.constant(8));
constraints.setWidth(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,Spring.constant(30));
layout.getConstraints(panel).setX(Spring.constant(7));
constraints.setWidth(Spring.constant(20));
layout.getConstraints(innerButton).setX(Spring.constant(17));
container.setSize(200,300);
layout.layoutContainer(container);
assertEquals(0,container.getX());
assertEquals(7,button.getX());
assertEquals(10,textField.getX());
assertEquals(7,panel.getX());
assertEquals(0,innerButton.getX());
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_SetY() throws Exception {
layout.getConstraints(container).setY(Spring.constant(5));
layout.getConstraints(button).setY(Spring.constant(6));
layout.getConstraints(button).setY(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setY(Spring.constant(8));
constraints.setHeight(Spring.constant(10));
constraints.setConstraint(SpringLayout.soUTH,Spring.constant(40));
layout.getConstraints(panel).setY(Spring.constant(6));
constraints.setHeight(Spring.constant(20));
layout.getConstraints(innerButton).setY(Spring.constant(15));
container.setSize(200,container.getY());
assertEquals(8,button.getY());
assertEquals(20,textField.getY());
assertEquals(6,panel.getY());
assertEquals(0,innerButton.getY());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testAddLayoutComponent() throws Exception {
Constraints constraints = new Constraints(Spring.constant(1),constraints);
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_SetHeight() throws Exception {
layout.getConstraints(container).setHeight(Spring.constant(5));
layout.getConstraints(button).setHeight(Spring.constant(6));
layout.getConstraints(button).setHeight(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setHeight(Spring.constant(8));
constraints.setY(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,innerButton.getHeight());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_SetWidth() throws Exception {
layout.getConstraints(container).setWidth(Spring.constant(5));
layout.getConstraints(button).setWidth(Spring.constant(6));
layout.getConstraints(button).setWidth(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setWidth(Spring.constant(8));
constraints.setX(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,innerButton.getWidth());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_SetX() throws Exception {
layout.getConstraints(container).setX(Spring.constant(5));
layout.getConstraints(button).setX(Spring.constant(6));
layout.getConstraints(button).setX(Spring.constant(7));
Constraints constraints = layout.getConstraints(textField);
constraints.setX(Spring.constant(8));
constraints.setWidth(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,innerButton.getX());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_SetY() throws Exception {
layout.getConstraints(container).setY(Spring.constant(5));
layout.getConstraints(button).setY(Spring.constant(6));
layout.getConstraints(button).setY(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setY(Spring.constant(8));
constraints.setHeight(Spring.constant(10));
constraints.setConstraint(SpringLayout.soUTH,innerButton.getY());
}
项目:cn1
文件:SpringLayoutTest.java
public void testGetConstraints() {
Constraints constraints = layout.getConstraints(null);
assertNotNull(constraints);
layout.addLayoutComponent(component,"not_constraints");
constraints = layout.getConstraints(component);
assertNotNull(constraints);
SpringTest.assertSizes(0,constraints.getX());
SpringTest.assertSizes(0,constraints.getY());
SpringTest.assertSizes(component.getMinimumSize().width,component.getPreferredSize().width,component.getMaximumSize().width,constraints.getWidth());
SpringTest.assertSizes(component.getMinimumSize().height,component.getPreferredSize().height,component.getMaximumSize().height,constraints.getHeight());
layout.addLayoutComponent(component,null);
constraints = layout.getConstraints(component);
assertNotNull(constraints);
SpringTest.assertSizes(0,constraints.getHeight());
Constraints componentConstraints = new SpringLayout.Constraints(component);
layout.addLayoutComponent(component,constraints);
constraints = layout.getConstraints(component);
assertFalse(componentConstraints.equals(constraints));
SpringTest.assertValues(componentConstraints.getX(),constraints.getX());
SpringTest.assertValues(componentConstraints.getY(),constraints.getY());
SpringTest.assertValues(componentConstraints.getWidth(),constraints.getWidth());
SpringTest.assertValues(componentConstraints.getHeight(),constraints.getHeight());
assertNotNull(layout.getConstraints(new JLabel()));
}
项目:cn1
文件:SpringLayoutTest.java
public void testRemoveLayoutComponent() {
layout.removeLayoutComponent(null);
layout.removeLayoutComponent(new JLabel());
layout.addLayoutComponent(component,new SpringLayout.Constraints(component));
layout.removeLayoutComponent(null);
layout.removeLayoutComponent(new JLabel());
JPanel panel = new JPanel(layout);
panel.add(component);
Constraints constraints1 = layout.getConstraints(component);
layout.removeLayoutComponent(component);
Constraints constraints2 = layout.getConstraints(component);
assertNotSame(constraints1,constraints2);
SpringTest.assertSizes(0,constraints2.getX());
SpringTest.assertSizes(0,constraints2.getY());
component = new JTextField();
JLabel label = new JLabel("label");
setComponentSizes(label,Spring.constant(5),Spring.constant(10));
panel.add(component);
panel.add(label);
layout.getConstraints(label).setX(Spring.constant(15));
layout.putConstraint(SpringLayout.WEST,component,5,SpringLayout.EAST,label);
layout.layoutContainer(panel);
assertEquals(15,label.getX());
layout.removeLayoutComponent(label);
layout.layoutContainer(panel);
assertEquals(0,label.getX());
}
项目:cn1
文件:SpringLayoutTest.java
public void testInvalidateLayout() throws Exception {
JFrame frame = new JFrame("testMinimumLayoutSize");
frame.setContentPane(container);
layout = new SpringLayout();
container.setLayout(layout);
Constraints buttonConstraints = layout.getConstraints(button);
buttonConstraints.setHeight(Spring.constant(33,34,35));
Constraints containerConstraints = layout.getConstraints(container);
containerConstraints.setConstraint(SpringLayout.soUTH,buttonConstraints.getConstraint(SpringLayout.soUTH));
containerConstraints.setConstraint(SpringLayout.EAST,buttonConstraints.getConstraint(SpringLayout.EAST));
containerConstraints.setConstraint(SpringLayout.WEST,Spring.constant(3));
frame.pack();
frame.setVisible(true);
frame.setSize(100,200);
Spring width = buttonConstraints.getWidth();
if (isHarmony()) {
assertEquals(5,width.getValue());
} else {
assertEquals(115,width.getValue());
}
frame.setSize(200,300);
layout.invalidateLayout(container);
assertSame(width,buttonConstraints.getWidth());
if (isHarmony()) {
assertEquals(5,width.getValue());
}
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_GetHeight() throws Exception {
layout.getConstraints(container).setHeight(Spring.constant(5));
layout.getConstraints(button).setHeight(Spring.constant(6));
layout.getConstraints(button).setHeight(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setHeight(Spring.constant(8));
constraints.setY(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,300);
layout.layoutContainer(container);
SpringTest.assertSizes(5,layout.getConstraints(container).getHeight());
SpringTest.assertSizes(8,8,layout.getConstraints(button).getHeight());
SpringTest.assertSizes(8,layout.getConstraints(textField).getHeight());
SpringTest.assertSizes(6,6,layout.getConstraints(panel).getHeight());
SpringTest.assertSizes(15,15,layout.getConstraints(innerButton).getHeight());
container.setSize(200,300);
layout.layoutContainer(button);
SpringTest.assertSizes(8,layout.getConstraints(button).getHeight());
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_GetWidth() throws Exception {
layout.getConstraints(container).setWidth(Spring.constant(5));
layout.getConstraints(button).setWidth(Spring.constant(6));
layout.getConstraints(button).setWidth(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setWidth(Spring.constant(8));
constraints.setX(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,layout.getConstraints(container).getWidth());
SpringTest.assertSizes(8,layout.getConstraints(button).getWidth());
SpringTest.assertSizes(20,20,layout.getConstraints(textField).getWidth());
SpringTest.assertSizes(6,layout.getConstraints(panel).getWidth());
SpringTest.assertSizes(15,layout.getConstraints(innerButton).getWidth());
container.setSize(200,layout.getConstraints(button).getWidth());
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_GetX() throws Exception {
layout.getConstraints(container).setX(Spring.constant(5));
layout.getConstraints(button).setX(Spring.constant(6));
layout.getConstraints(button).setX(Spring.constant(7));
Constraints constraints = layout.getConstraints(textField);
constraints.setX(Spring.constant(8));
constraints.setWidth(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,300);
layout.layoutContainer(container);
SpringTest.assertSizes(0,layout.getConstraints(container).getX());
SpringTest.assertSizes(7,7,layout.getConstraints(button).getX());
SpringTest.assertSizes(10,10,layout.getConstraints(textField).getX());
SpringTest.assertSizes(7,layout.getConstraints(panel).getX());
SpringTest.assertSizes(17,17,layout.getConstraints(innerButton).getX());
container.setSize(200,300);
layout.layoutContainer(button);
SpringTest.assertSizes(0,layout.getConstraints(button).getX());
}
项目:cn1
文件:SpringLayoutTest.java
public void testConstraints_GetY() throws Exception {
layout.getConstraints(container).setY(Spring.constant(5));
layout.getConstraints(button).setY(Spring.constant(6));
layout.getConstraints(button).setY(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setY(Spring.constant(8));
constraints.setHeight(Spring.constant(10));
constraints.setConstraint(SpringLayout.soUTH,layout.getConstraints(container).getY());
SpringTest.assertSizes(8,layout.getConstraints(button).getY());
SpringTest.assertSizes(20,layout.getConstraints(textField).getY());
SpringTest.assertSizes(6,layout.getConstraints(panel).getY());
SpringTest.assertSizes(15,layout.getConstraints(innerButton).getY());
container.setSize(200,layout.getConstraints(button).getY());
}
项目:cn1
文件:SpringLayoutTest.java
private void assertEdges(final Constraints constraints,final int west,final int east,final int north,final int south) {
assertEquals(west,constraints.getConstraint(SpringLayout.WEST).getValue());
assertEquals(east,constraints.getConstraint(SpringLayout.EAST).getValue());
assertEquals(north,constraints.getConstraint(SpringLayout.norTH).getValue());
assertEquals(south,constraints.getConstraint(SpringLayout.soUTH).getValue());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testGetConstraints() {
Constraints constraints = layout.getConstraints(null);
assertNotNull(constraints);
layout.addLayoutComponent(component,constraints.getHeight());
assertNotNull(layout.getConstraints(new JLabel()));
}
项目:freeVM
文件:SpringLayoutTest.java
public void testRemoveLayoutComponent() {
layout.removeLayoutComponent(null);
layout.removeLayoutComponent(new JLabel());
layout.addLayoutComponent(component,label.getX());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testInvalidateLayout() throws Exception {
JFrame frame = new JFrame("testMinimumLayoutSize");
frame.setContentPane(container);
layout = new SpringLayout();
container.setLayout(layout);
Constraints buttonConstraints = layout.getConstraints(button);
buttonConstraints.setHeight(Spring.constant(33,width.getValue());
}
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_GetHeight() throws Exception {
layout.getConstraints(container).setHeight(Spring.constant(5));
layout.getConstraints(button).setHeight(Spring.constant(6));
layout.getConstraints(button).setHeight(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setHeight(Spring.constant(8));
constraints.setY(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,layout.getConstraints(button).getHeight());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_GetWidth() throws Exception {
layout.getConstraints(container).setWidth(Spring.constant(5));
layout.getConstraints(button).setWidth(Spring.constant(6));
layout.getConstraints(button).setWidth(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setWidth(Spring.constant(8));
constraints.setX(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,layout.getConstraints(button).getWidth());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_GetX() throws Exception {
layout.getConstraints(container).setX(Spring.constant(5));
layout.getConstraints(button).setX(Spring.constant(6));
layout.getConstraints(button).setX(Spring.constant(7));
Constraints constraints = layout.getConstraints(textField);
constraints.setX(Spring.constant(8));
constraints.setWidth(Spring.constant(10));
constraints.setConstraint(SpringLayout.EAST,layout.getConstraints(button).getX());
}
项目:freeVM
文件:SpringLayoutTest.java
public void testConstraints_GetY() throws Exception {
layout.getConstraints(container).setY(Spring.constant(5));
layout.getConstraints(button).setY(Spring.constant(6));
layout.getConstraints(button).setY(Spring.constant(8));
Constraints constraints = layout.getConstraints(textField);
constraints.setY(Spring.constant(8));
constraints.setHeight(Spring.constant(10));
constraints.setConstraint(SpringLayout.soUTH,layout.getConstraints(button).getY());
}
项目:freeVM
文件:SpringLayoutTest.java
private void assertEdges(final Constraints constraints,constraints.getConstraint(SpringLayout.soUTH).getValue());
}
项目:cn1
文件:SpringLayoutTest.java
public void testSpringLayout() {
SpringLayout.Constraints constrains = new SpringLayout.Constraints();
assertNull(constrains.getX());
assertNull(constrains.getY());
assertNull(constrains.getWidth());
assertNull(constrains.getHeight());
constrains = new SpringLayout.Constraints(Spring.width(component),Spring.constant(0));
assertNull(constrains.getWidth());
assertNull(constrains.getHeight());
SpringTest.assertSizes(0,constrains.getY());
SpringTest.assertSizes(component.getMinimumSize().width,constrains.getX());
assertNull(constrains.getWidth());
assertNull(constrains.getHeight());
constrains = new SpringLayout.Constraints(component);
SpringTest.assertSizes(0,constrains.getX());
SpringTest.assertSizes(0,constrains.getWidth());
SpringTest.assertSizes(component.getMinimumSize().height,constrains.getHeight());
constrains = new SpringLayout.Constraints(Spring.constant(1),Spring.constant(4));
SpringTest.assertSizes(1,1,constrains.getX());
SpringTest.assertSizes(2,2,constrains.getY());
SpringTest.assertSizes(3,3,constrains.getWidth());
SpringTest.assertSizes(4,4,null);
SpringTest.assertSizes(1,constrains.getX());
Container container = new JPanel();
container.setLayout(layout);
container.add(new JLabel(""));
constrains = layout.getConstraints(component);
SpringTest.assertSizes(0,constrains.getHeight());
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。