use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class NlPreviewImagePanelTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myFile = myFixture.copyFileToProject(BASE_PATH + "colors.xml", "res/values/colors.xml");
myModel = createModel();
mySurface = new DesignSurface(getProject(), false);
mySurface.setModel(myModel);
myDependencyManager = mock(DependencyManager.class);
IconPreviewFactory iconPreviewFactory = mock(IconPreviewFactory.class);
Runnable closeToolWindowCallback = mock(Runnable.class);
//noinspection UndesirableClassUsage
BufferedImage image = new BufferedImage(250, 50, TYPE_INT_ARGB);
when(myDependencyManager.getProject()).thenReturn(getProject());
when(iconPreviewFactory.renderDragImage(any(Palette.Item.class), any(ScreenView.class))).thenReturn(image);
myPanel = new NlPreviewImagePanel(iconPreviewFactory, myDependencyManager, closeToolWindowCallback);
myPanel.setDesignSurface(mySurface);
myPanel.setItem(PaletteTestCase.findItem(NlPaletteModel.get(getProject()).getPalette(LAYOUT), BUTTON));
myPanel.setSize(WIDTH, HEIGHT);
myPanel.doLayout();
paint();
myRepaintManager = mock(RepaintManager.class);
RepaintManager.setCurrentManager(myRepaintManager);
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class NlEditorFixture method startResizeInteraction.
/**
* Moves the mouse to the resize corner of the screen view, and presses the left mouse button.
* That starts the canvas resize interaction.
*
* @see #resizeToAndroidSize(int, int)
* @see #endResizeInteraction()
*/
public NlEditorFixture startResizeInteraction() {
DesignSurface surface = myDesignSurfaceFixture.target();
ScreenView screenView = surface.getCurrentScreenView();
Dimension size = screenView.getSize();
robot().pressMouse(surface, new Point(screenView.getX() + size.width + 24, screenView.getY() + size.height + 24));
return this;
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class MockupTest method testGetBounds_0000_Position.
public void testGetBounds_0000_Position() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, "0 0 0 0", null);
final NlComponent component = model.getComponents().get(0);
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
DesignSurface mockSurface = mock(DesignSurface.class);
when(mockSurface.getScale()).thenReturn(1.0);
final ScreenView screenView = new ScreenView(mockSurface, ScreenView.ScreenViewType.BLUEPRINT, model);
final Rectangle componentSwingCoordinates = new Rectangle(0, 0, Coordinates.getSwingDimension(screenView, 1000), // See createModel for the 1000 value
Coordinates.getSwingDimension(screenView, 1000));
final Rectangle destinationRectangle = mockup.getScreenBounds(screenView);
assertEquals(componentSwingCoordinates, destinationRectangle);
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class ResizeFixture method pressKey.
public ResizeFixture pressKey(@MagicConstant(flagsFromClass = KeyEvent.class) int keyCode, char keyChar) {
if (keyCode == KeyEvent.VK_SHIFT) {
myModifiers |= InputEvent.SHIFT_MASK;
}
if (keyCode == KeyEvent.VK_META) {
myModifiers |= InputEvent.META_MASK;
}
if (keyCode == KeyEvent.VK_CONTROL) {
myModifiers |= InputEvent.CTRL_MASK;
}
if (keyCode == KeyEvent.VK_ALT) {
myModifiers |= InputEvent.ALT_MASK;
}
DesignSurface surface = myScreen.getSurface();
KeyEvent event = new KeyEventBuilder(keyCode, keyChar).withSource(surface).build();
myInteraction.keyPressed(event);
return this;
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class LayoutTestUtilities method createSurface.
public static DesignSurface createSurface() {
JComponent layeredPane = new JPanel();
DesignSurface surface = mock(DesignSurface.class);
when(surface.getLayeredPane()).thenReturn(layeredPane);
return surface;
}
Aggregations