private static BoundingBox computeBoundingBox(Layout layout, VertexRef vertRef) { return new BoundingBox(layout.getLocation(vertRef), 100, 100); }
private static void applySavedLocations(Map<VertexRef, Point> locations, Layout layout) { for(VertexRef ref : locations.keySet()) { layout.setLocation(ref, locations.get(ref)); } }
final BoundingBox layoutBounds = graphLayout.computeBoundingBox(new ArrayList<>(sortedVertices)); final BoundingBox grid = calculateGrid(numberOfVertices, layoutBounds.getWidth(), layoutBounds.getHeight()); break; graphLayout.setLocation(sortedVertices.get(k++), new Point(x * ELBOW_ROOM * 2, y * ELBOW_ROOM * 2));
for (Vertex vertex : vertices) { PointEntity pointEntity = layoutEntity.getPosition(vertex.getNamespace(), vertex.getId()); layout.setLocation(vertex, new Point(pointEntity.getX(), pointEntity.getY())); final Layout layout = graph.getLayout(); final long notLayedOutCount = vertices.stream().filter(v -> { Point location = layout.getLocation(v); return location.getX() == 0 && location.getY() == 0; }).count(); layout.setLocation(vertex, new Point(vertex.getX(), vertex.getY())); Point p = layout.getLocation(vertex); layout.setLocation(vertex, p);
@Override public void visitVertex(Vertex vertex) throws PaintException { boolean selected = isSelected(m_graphContainer.getSelectionManager(), vertex); Point initialLocation = m_layout.getInitialLocation(vertex); Point location = m_layout.getLocation(vertex); SharedVertex v = new SharedVertex(); v.setKey(vertex.getKey()); //TODO cast to int for now v.setInitialX((int)initialLocation.getX()); v.setInitialY((int)initialLocation.getY()); v.setX((int)location.getX()); v.setY((int) location.getY()); v.setSelected(selected); v.setStatus(getStatus(vertex)); v.setStatusCount(getStatusCount(vertex)); v.setSVGIconId(getIconId(vertex)); v.setLabel(vertex.getLabel()); v.setTooltipText(getTooltipText(vertex)); v.setStyleName(getVertexStyle(vertex, selected)); v.setTargets(getTargets(vertex)); v.setEdgePathOffset(getEdgePathOffset(vertex)); m_vertices.add(v); }
private void computeBoundsForSelected(SelectionContext selectionContext) { if(selectionContext.getSelectedVertexRefs().size() > 0) { Collection<? extends Vertex> visible = m_graphContainer.getGraph().getDisplayVertices(); Collection<VertexRef> selected = selectionContext.getSelectedVertexRefs(); Collection<VertexRef> vRefs = new ArrayList<>(); for(VertexRef vRef : selected) { if(visible.contains(vRef)) { vRefs.add(vRef); } } getViewManager().setBoundingBox(m_graphContainer.getGraph().getLayout().computeBoundingBox(vRefs)); } else { getViewManager().setBoundingBox(m_graphContainer.getGraph().getLayout().getBounds()); } }
private void setGraph(Graph graph) { m_graph = graph; getViewManager().setMapBounds(graph.getLayout().getBounds()); }
private void rebuildGraph() { Graph oldGraph = m_graph; m_graph = getTopologyServiceClient().getGraph(getCriteria(), getSemanticZoomLevel()); unselectElementsWhichAreNotVisibleAnymore(m_graph, m_selectionManager); removeVerticesWhichAreNotVisible(m_graph.getDisplayVertices()); // We must restore the old layout, otherwise the layout is in a weird state if (oldGraph != null) { m_graph.setLayout(oldGraph.getLayout()); m_graph.getLayout().updateLocations(new ArrayList<>(m_graph.getDisplayVertices())); } }
@Override public void centerSearchSuggestion(SearchSuggestion searchSuggestion) { LOG.debug("SearchBox->centerSearchSuggestion: called with searchSuggestion: {}", searchSuggestion); SearchResult searchResult = new SearchResult(searchSuggestion.getNamespace(), searchSuggestion.getId(), searchSuggestion.getLabel(), searchSuggestion.getQuery(), searchSuggestion.isCollapsible(), searchSuggestion.isCollapsed()); Set<VertexRef> vRefs = new TreeSet<>(); Multiset<SearchProvider> keys = m_suggestionMap.keys(); for(SearchProvider key : keys){ Collection<SearchResult> searchResults = m_suggestionMap.get(key); if(searchResults.contains(searchResult)) { key.onCenterSearchResult(searchResult, m_operationContext.getGraphContainer()); vRefs.addAll(key.getVertexRefsBy(searchResult, m_operationContext.getGraphContainer())); break; } } // Hack for now, change to a better way. VertexHopCriteria criteria = VertexHopGraphProvider.getWrappedVertexHopCriteria(m_operationContext.getGraphContainer()); DefaultVertexRef vertexRef = new DefaultVertexRef(searchResult.getNamespace(), searchResult.getId(), searchResult.getLabel()); if(criteria.getVertices().contains(vertexRef)){ vRefs.add(vertexRef); } GraphContainer graphContainer = m_operationContext.getGraphContainer(); MapViewManager mapViewManager = graphContainer.getMapViewManager(); mapViewManager.setBoundingBox(graphContainer.getGraph().getLayout().computeBoundingBox(vRefs)); }
public boolean isPersistedLayoutEqualToCurrentLayout(Graph graph) { LayoutEntity layoutEntity = loadLayout(graph); if (layoutEntity != null) { // If we have a layout persisted, we verify if it is equal. final Map<VertexRef, Point> persistedLocations = layoutEntity.getVertexPositions() .stream() .collect(Collectors.toMap((Function<VertexPositionEntity, VertexRef>) vertexPositionEntity -> { VertexRefEntity vertexRefEntity = vertexPositionEntity.getVertexRef(); return new DefaultVertexRef(vertexRefEntity.getNamespace(), vertexRefEntity.getId()); }, vertexPositionEntity -> { PointEntity position = vertexPositionEntity.getPosition(); return new Point(position.getX(), position.getY()); })); // The locations may contain elements currently not visible, we filter them final Map<VertexRef, Point> manualLocations = new HashMap<>(); graph.getLayout().getLocations().forEach((key, value) -> { if (persistedLocations.containsKey(key)) { // layoutEntity stores int coordinates, but manualLocations are stored as double. // Convert to int to make it comparable. manualLocations.put(key, new Point((int) value.getX(), (int) value.getY())); } }); final boolean layoutIsEqual = manualLocations.equals(persistedLocations); return layoutIsEqual; } return false; // We don't have anything persisted, so they are not equal } }
for (Vertex vertex : vertices) { PointEntity pointEntity = layoutEntity.getPosition(vertex.getNamespace(), vertex.getId()); layout.setLocation(vertex, new Point(pointEntity.getX(), pointEntity.getY())); final Layout layout = graph.getLayout(); final long notLayedOutCount = vertices.stream().filter(v -> { Point location = layout.getLocation(v); return location.getX() == 0 && location.getY() == 0; }).count(); layout.setLocation(vertex, new Point(vertex.getX(), vertex.getY())); Point p = layout.getLocation(vertex); layout.setLocation(vertex, p);
@Override public void visitVertex(Vertex vertex) throws PaintException { boolean selected = isSelected(m_graphContainer.getSelectionManager(), vertex); Point initialLocation = m_layout.getInitialLocation(vertex); Point location = m_layout.getLocation(vertex); SharedVertex v = new SharedVertex(); v.setKey(vertex.getKey()); //TODO cast to int for now v.setInitialX((int)initialLocation.getX()); v.setInitialY((int)initialLocation.getY()); v.setX((int)location.getX()); v.setY((int) location.getY()); v.setSelected(selected); v.setStatus(getStatus(vertex)); v.setStatusCount(getStatusCount(vertex)); v.setSVGIconId(getIconId(vertex)); v.setLabel(vertex.getLabel()); v.setTooltipText(getTooltipText(vertex)); v.setStyleName(getVertexStyle(vertex, selected)); v.setTargets(getTargets(vertex)); v.setEdgePathOffset(getEdgePathOffset(vertex)); m_vertices.add(v); }
private void computeBoundsForSelected(SelectionContext selectionContext) { if(selectionContext.getSelectedVertexRefs().size() > 0) { Collection<? extends Vertex> visible = m_graphContainer.getGraph().getDisplayVertices(); Collection<VertexRef> selected = selectionContext.getSelectedVertexRefs(); Collection<VertexRef> vRefs = new ArrayList<>(); for(VertexRef vRef : selected) { if(visible.contains(vRef)) { vRefs.add(vRef); } } getViewManager().setBoundingBox(m_graphContainer.getGraph().getLayout().computeBoundingBox(vRefs)); } else { getViewManager().setBoundingBox(m_graphContainer.getGraph().getLayout().getBounds()); } }
private void setGraph(Graph graph) { m_graph = graph; getViewManager().setMapBounds(graph.getLayout().getBounds()); }
private void rebuildGraph() { Graph oldGraph = m_graph; m_graph = getTopologyServiceClient().getGraph(getCriteria(), getSemanticZoomLevel()); unselectElementsWhichAreNotVisibleAnymore(m_graph, m_selectionManager); removeVerticesWhichAreNotVisible(m_graph.getDisplayVertices()); // We must restore the old layout, otherwise the layout is in a weird state if (oldGraph != null) { m_graph.setLayout(oldGraph.getLayout()); m_graph.getLayout().updateLocations(new ArrayList<>(m_graph.getDisplayVertices())); } }
@Override public void centerSearchSuggestion(SearchSuggestion searchSuggestion) { LOG.debug("SearchBox->centerSearchSuggestion: called with searchSuggestion: {}", searchSuggestion); SearchResult searchResult = new SearchResult(searchSuggestion.getNamespace(), searchSuggestion.getId(), searchSuggestion.getLabel(), searchSuggestion.getQuery(), searchSuggestion.isCollapsible(), searchSuggestion.isCollapsed()); Set<VertexRef> vRefs = new TreeSet<>(); Multiset<SearchProvider> keys = m_suggestionMap.keys(); for(SearchProvider key : keys){ Collection<SearchResult> searchResults = m_suggestionMap.get(key); if(searchResults.contains(searchResult)) { key.onCenterSearchResult(searchResult, m_operationContext.getGraphContainer()); vRefs.addAll(key.getVertexRefsBy(searchResult, m_operationContext.getGraphContainer())); break; } } // Hack for now, change to a better way. VertexHopCriteria criteria = VertexHopGraphProvider.getWrappedVertexHopCriteria(m_operationContext.getGraphContainer()); DefaultVertexRef vertexRef = new DefaultVertexRef(searchResult.getNamespace(), searchResult.getId(), searchResult.getLabel()); if(criteria.getVertices().contains(vertexRef)){ vRefs.add(vertexRef); } GraphContainer graphContainer = m_operationContext.getGraphContainer(); MapViewManager mapViewManager = graphContainer.getMapViewManager(); mapViewManager.setBoundingBox(graphContainer.getGraph().getLayout().computeBoundingBox(vRefs)); }
public boolean isPersistedLayoutEqualToCurrentLayout(Graph graph) { LayoutEntity layoutEntity = loadLayout(graph); if (layoutEntity != null) { // If we have a layout persisted, we verify if it is equal. final Map<VertexRef, Point> persistedLocations = layoutEntity.getVertexPositions() .stream() .collect(Collectors.toMap((Function<VertexPositionEntity, VertexRef>) vertexPositionEntity -> { VertexRefEntity vertexRefEntity = vertexPositionEntity.getVertexRef(); return new DefaultVertexRef(vertexRefEntity.getNamespace(), vertexRefEntity.getId()); }, vertexPositionEntity -> { PointEntity position = vertexPositionEntity.getPosition(); return new Point(position.getX(), position.getY()); })); // The locations may contain elements currently not visible, we filter them final Map<VertexRef, Point> manualLocations = new HashMap<>(); graph.getLayout().getLocations().forEach((key, value) -> { if (persistedLocations.containsKey(key)) { // layoutEntity stores int coordinates, but manualLocations are stored as double. // Convert to int to make it comparable. manualLocations.put(key, new Point((int) value.getX(), (int) value.getY())); } }); final boolean layoutIsEqual = manualLocations.equals(persistedLocations); return layoutIsEqual; } return false; // We don't have anything persisted, so they are not equal } }
private static void applySavedLocations(Map<VertexRef, Point> locations, Layout layout) { for(VertexRef ref : locations.keySet()) { layout.setLocation(ref, locations.get(ref)); } }
private static BoundingBox computeBoundingBox(Layout layout, VertexRef vertRef) { return new BoundingBox(layout.getLocation(vertRef), 100, 100); }
final BoundingBox layoutBounds = graphLayout.computeBoundingBox(new ArrayList<>(sortedVertices)); final BoundingBox grid = calculateGrid(numberOfVertices, layoutBounds.getWidth(), layoutBounds.getHeight()); break; graphLayout.setLocation(sortedVertices.get(k++), new Point(x * ELBOW_ROOM * 2, y * ELBOW_ROOM * 2));