Browse Source

REPORT-34737 绝对画布中的组件可视状态下移到侧边后组件移出画布可见区域

bugfix/10.0
pengda 5 years ago
parent
commit
4ca1e7cdfb
  1. 5
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 46
      designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapterTest.java

5
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -310,14 +310,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
public void fix(XCreator creator ,int x, int y) {
int height = creator.getHeight();
int width = creator.getWidth();
//坐标小于0时让它还在容器内
if (x < 0) {
x = container.getX();
x = 0;
} else if (x + creator.getWidth() > container.getWidth()) {
x = container.getWidth() - width;
}
if (y < 0) {
y = container.getY();
y = 0;
} else if (y + creator.getHeight() > container.getHeight()) {
y = container.getHeight() - height;
}

46
designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapterTest.java

@ -0,0 +1,46 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.form.ui.Button;
import com.fr.form.ui.container.WAbsoluteLayout;
import java.awt.Dimension;
import junit.framework.TestCase;
import org.junit.Assert;
public class FRAbsoluteLayoutAdapterTest extends TestCase {
@Override
protected void setUp() throws Exception {
DaoContext.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
}
public void testFix(){
WAbsoluteLayout layout =new WAbsoluteLayout();
XWAbsoluteLayout container =new XWAbsoluteLayout(layout);
container.setBounds(0,320,400,160);
FRAbsoluteLayoutAdapter frAbsoluteLayoutAdapter = new FRAbsoluteLayoutAdapter(container);
XCreator button = new XButton(new Button(),new Dimension(88,40));
frAbsoluteLayoutAdapter.fix(button,-1,-1);
Assert.assertEquals(0,button.getX());
Assert.assertEquals(0,button.getY());
frAbsoluteLayoutAdapter.fix(button,350,200);
Assert.assertEquals(312,button.getX());
Assert.assertEquals(120,button.getY());
}
@Override
protected void tearDown() throws Exception {
DaoContext.setEntityDao(null);
DaoContext.setClassHelperDao(null);
DaoContext.setXmlEntityDao(null);
}
}
Loading…
Cancel
Save