use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class RelativeLayoutHandler method createResizeHandler.
@Override
@Nullable
public ResizeHandler createResizeHandler(@NotNull ViewEditor editor, @NotNull NlComponent component, @Nullable SegmentType horizontalEdgeType, @Nullable SegmentType verticalEdgeType) {
NlComponent parent = component.getParent();
if (parent == null) {
return null;
}
final RelativeResizeHandler resizeHandler = new RelativeResizeHandler(editor, parent, component, horizontalEdgeType, verticalEdgeType);
return new ResizeHandler(editor, this, component, horizontalEdgeType, verticalEdgeType) {
@Nullable
@Override
public String update(@AndroidCoordinate int x, @AndroidCoordinate int y, int modifiers, @NotNull @AndroidCoordinate Rectangle newBounds) {
super.update(x, y, modifiers, newBounds);
resizeHandler.updateResize(component, newBounds, modifiers);
return null;
}
@Override
public void commit(@AndroidCoordinate int px, @AndroidCoordinate int py, int modifiers, @NotNull @AndroidCoordinate Rectangle newBounds) {
resizeHandler.removeCycles();
resizeHandler.applyConstraints(component);
}
@Override
public void paint(@NotNull NlGraphics graphics) {
GuidelinePainter.paint(graphics, resizeHandler);
}
};
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class GridInfo method initChildren.
private void initChildren() throws NoSuchFieldException, IllegalAccessException {
children = new NlComponent[rowCount][columnCount];
assert layout.children != null;
for (NlComponent child : layout.children) {
ChildInfo info = getInfo(child);
int endRow = Math.min(info.getRow2(), rowCount);
int endColumn = Math.min(info.getColumn2(), columnCount);
for (int row = info.getRow1(); row < endRow; row++) {
for (int column = info.getColumn1(); column < endColumn; column++) {
children[row][column] = child;
}
}
}
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class GroupDragHandler method createOrderToItemMultimap.
@NotNull
private Multimap<Integer, NlComponent> createOrderToItemMultimap(@NotNull Iterable<NlComponent> group) {
Object draggedItem = myItems.get(0);
Multimap<Integer, NlComponent> orderToItemMultimap = ArrayListMultimap.create();
for (NlComponent item : group) {
if (item == draggedItem) {
continue;
}
Integer order = getOrderInCategory(item);
if (order != null) {
orderToItemMultimap.put(order, item);
}
}
return orderToItemMultimap;
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class DependencyGraph method dependsOn.
/**
* Returns the set of views that depend on the given node in either the horizontal or
* vertical direction
*
* @param nodes the set of nodes that we want to compute the transitive dependencies
* for
* @param vertical if true, look for vertical edge dependencies, otherwise look for
* horizontal edge dependencies
* @return the set of nodes that directly or indirectly depend on the given nodes in
* the given direction
*/
public Set<NlComponent> dependsOn(Collection<? extends NlComponent> nodes, boolean vertical) {
List<ViewData> reachable = new ArrayList<ViewData>();
// Traverse the graph of constraints and determine all nodes affected by
// this node
Set<ViewData> visiting = new HashSet<ViewData>();
for (NlComponent node : nodes) {
ViewData view = myNodeToView.get(node);
if (view != null) {
findBackwards(view, visiting, reachable, vertical, view);
}
}
Set<NlComponent> dependents = new HashSet<NlComponent>(reachable.size());
for (ViewData v : reachable) {
dependents.add(v.node);
}
return dependents;
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class GroupDragHandler method drawActionBarGroupDropZoneLines.
private void drawActionBarGroupDropZoneLines(@NotNull NlGraphics graphics) {
List<NlComponent> items = myActionBar.getItems();
int midpointX = myActiveItem.getMidpointX();
graphics.useStyle(NlDrawingStyle.DROP_ZONE);
for (int i = 1, size = items.size(); i < size; i++) {
NlComponent item = items.get(i);
if (myActiveItem == items.get(i - 1)) {
if (lastX < midpointX) {
graphics.drawLeft(item);
}
} else if (myActiveItem == item) {
if (lastX >= midpointX) {
graphics.drawLeft(item);
}
} else {
graphics.drawLeft(item);
}
}
}
Aggregations