use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.
the class SceneDecorator method buildListChildren.
/**
* This is responsible for setting the clip and building the list for this component's children
*
* @param list
* @param time
* @param sceneContext
* @param component
*/
protected void buildListChildren(@NotNull DisplayList list, long time, @NotNull SceneContext sceneContext, @NotNull SceneComponent component) {
ArrayList<SceneComponent> children = component.getChildren();
if (children.size() > 0) {
Rectangle rect = new Rectangle();
component.fillRect(rect);
DisplayList.UNClip unClip = list.addClip(sceneContext, rect);
for (SceneComponent child : children) {
child.buildDisplayList(time, list, sceneContext);
}
list.add(unClip);
}
}
use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.
the class SceneDisplayListSortedTest method testBasicScene.
public void testBasicScene() {
String simpleList = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawComponentBackground,10,10,990,20,1\n" + "DrawComponentFrame,10,10,990,20,1\n" + "Clip,10,10,990,20\n" + "DrawComponentBackground,10,10,990,20,1\n" + "DrawTextRegion,10,10,990,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,10,10,990,20,1\n" + "UNClip\n" + "DrawComponentBackground,10,100,990,20,1\n" + "DrawComponentFrame,10,100,990,20,1\n" + "Clip,10,100,990,20\n" + "DrawComponentBackground,10,100,990,20,1\n" + "DrawTextRegion,10,100,990,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,10,100,990,20,1\n" + "UNClip\n" + "UNClip\n";
assertEquals(simpleList, myInteraction.getDisplayList().serialize());
DisplayList disp = DisplayList.getDisplayList(simpleList);
assertEquals(simpleList, DisplayList.getDisplayList(simpleList).serialize());
//noinspection UndesirableClassUsage
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
disp.paint(img.createGraphics(), SceneContext.get());
assertEquals(17, disp.getCommands().size());
String result = disp.generateSortedDisplayList(SceneContext.get());
String sorted = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawComponentBackground,10,10,990,20,1\n" + "DrawComponentFrame,10,10,990,20,1\n" + "Clip,10,10,990,20\n" + "DrawComponentBackground,10,10,990,20,1\n" + "DrawComponentFrame,10,10,990,20,1\n" + "DrawTextRegion,10,10,990,20,0,false,false,5,5,\"\"\n" + "UNClip\n" + "\n" + "DrawComponentBackground,10,100,990,20,1\n" + "DrawComponentFrame,10,100,990,20,1\n" + "Clip,10,100,990,20\n" + "DrawComponentBackground,10,100,990,20,1\n" + "DrawComponentFrame,10,100,990,20,1\n" + "DrawTextRegion,10,100,990,20,0,false,false,5,5,\"\"\n" + "UNClip\n" + "\n" + "UNClip\n\n";
assertEquals(sorted, result);
disp.clear();
}
use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.
the class SceneDisplayListTest2 method testBasicScene.
public void testBasicScene() {
myScreen.get("@id/button").expectXml("<TextView\n" + " android:id=\"@id/button\"\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"20dp\"\n" + " app:layout_constraintLeft_toLeftOf=\"parent\"\n" + " app:layout_constraintRight_toRightOf=\"parent\"\n" + " app:layout_constraintTop_toTopOf=\"parent\"\n" + " app:layout_constraintBottom_toBottomOf=\"parent\"/>");
String simpleList = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawComponentBackground,450,490,100,20,1\n" + "DrawTextRegion,450,490,100,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,450,490,100,20,1\n" + "DrawConnection,2,450x490x100x20,0,0x0x1000x1000,0,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,1,0x0x1000x1000,1,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,2,0x0x1000x1000,2,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,3,0x0x1000x1000,3,1,false,0,0,false,0.5\n" + "UNClip\n";
assertEquals(simpleList, myInteraction.getDisplayList().serialize());
DisplayList disp = DisplayList.getDisplayList(simpleList);
assertEquals(simpleList, DisplayList.getDisplayList(simpleList).serialize());
//noinspection UndesirableClassUsage
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
disp.paint(img.createGraphics(), SceneContext.get());
assertEquals(10, disp.getCommands().size());
disp.clear();
}
use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.
the class SceneDisplayListTest4 method testBasicScene.
public void testBasicScene() {
myScreen.get("@+id/a").expectXml("<TextView\n" + " android:id=\"@+id/a\"\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"20dp\"\n" + " app:layout_constraintLeft_toLeftOf=\"parent\"\n" + " app:layout_constraintRight_toLeftOf=\"@+id/b\"\n" + " app:layout_constraintTop_toTopOf=\"parent\"\n" + " app:layout_constraintBottom_toBottomOf=\"parent\"/>");
String list = myInteraction.getDisplayList().serialize();
assertEquals(myInteraction.getDisplayList().serialize(), list);
DisplayList disp = DisplayList.getDisplayList(list);
assertEquals(list, DisplayList.getDisplayList(list).serialize());
//noinspection UndesirableClassUsage
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
disp.paint(img.createGraphics(), SceneContext.get());
assertEquals(21, disp.getCommands().size());
disp.clear();
}
use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.
the class SceneDisplayListTest5 method testBasicScene.
public void testBasicScene() {
myScreen.get("@+id/button1").expectXml("<TextView\n" + " android:id=\"@+id/button1\"\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"20dp\"\n" + " app:layout_constraintLeft_toLeftOf=\"parent\"\n" + " app:layout_constraintRight_toRightOf=\"parent\"\n" + " app:layout_constraintTop_toTopOf=\"parent\"\n" + " app:layout_constraintBottom_toBottomOf=\"parent\"/>");
String simpleList = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawComponentBackground,450,490,100,20,1\n" + "DrawTextRegion,450,490,100,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,450,490,100,20,1\n" + "DrawConnection,2,450x490x100x20,0,0x0x1000x1000,0,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,1,0x0x1000x1000,1,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,2,0x0x1000x1000,2,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,3,0x0x1000x1000,3,1,false,0,0,false,0.5\n" + "DrawComponentBackground,450,490,100,20,1\n" + "DrawTextRegion,450,490,100,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,450,490,100,20,1\n" + "DrawConnection,4,450x490x100x20,0,450x490x100x20,0,0,true,0,0,false,0.5\n" + "DrawConnection,4,450x490x100x20,1,450x490x100x20,1,0,true,0,0,false,0.5\n" + "DrawConnection,5,450x490x100x0,5,450x490x100x0,5,0,false,0,0,false,0.0\n" + "UNClip\n";
assertEquals(simpleList, myInteraction.getDisplayList().serialize());
DisplayList disp = DisplayList.getDisplayList(simpleList);
assertEquals(simpleList, DisplayList.getDisplayList(simpleList).serialize());
//noinspection UndesirableClassUsage
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
disp.paint(img.createGraphics(), SceneContext.get());
assertEquals(16, disp.getCommands().size());
disp.clear();
}
Aggregations