protected static Dimension selectLayoutSize(GraphContainer g) { int vertexCount = g.getGraph().getDisplayVertices().size(); int spacing = ELBOW_ROOM; int diameter = (int)(vertexCount*spacing/Math.PI); return new Dimension(diameter+ELBOW_ROOM, diameter+ELBOW_ROOM); } }
protected static Dimension selectLayoutSize(GraphContainer g) { int vertexCount = g.getGraph().getDisplayVertices().size(); int spacing = ELBOW_ROOM; int diameter = (int)(vertexCount*spacing/Math.PI); return new Dimension(diameter+ELBOW_ROOM, diameter+ELBOW_ROOM); } }
@Override public void graphChanged(GraphContainer graphContainer){ if(graphContainer == null) return; Set<VertexRef> newDisplayableVertexRefs = new HashSet<VertexRef>(graphContainer.getGraph().getDisplayVertices()); if(!m_displayableVertexRefs.equals(newDisplayableVertexRefs)){ synchronized (m_displayableVertexRefs){ m_displayableVertexRefs.clear(); m_displayableVertexRefs.addAll(newDisplayableVertexRefs); } } fireVertexRefsUpdated(getVerticesInFocus(), graphContainer.getTopologyServiceClient()); }
@Override public void graphChanged(GraphContainer graphContainer){ if(graphContainer == null) return; Set<VertexRef> newDisplayableVertexRefs = new HashSet<VertexRef>(graphContainer.getGraph().getDisplayVertices()); if(!m_displayableVertexRefs.equals(newDisplayableVertexRefs)){ synchronized (m_displayableVertexRefs){ m_displayableVertexRefs.clear(); m_displayableVertexRefs.addAll(newDisplayableVertexRefs); } } fireVertexRefsUpdated(getVerticesInFocus(), graphContainer.getTopologyServiceClient()); }
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 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()); } }
@Override public void graphChanged(GraphContainer container) { Graph graph = container.getGraph(); setGraph(graph); if(!m_blockSelectionEvents){ computeBoundsForSelected(m_graphContainer.getSelectionManager()); } updateGraph(); }
@Override public void graphChanged(GraphContainer container) { Graph graph = container.getGraph(); setGraph(graph); if(!m_blockSelectionEvents){ computeBoundsForSelected(m_graphContainer.getSelectionManager()); } updateGraph(); }
public void showAllMap(){ getViewManager().setBoundingBox(m_graphContainer.getGraph().getLayout().getBounds()); }
public void showAllMap(){ getViewManager().setBoundingBox(m_graphContainer.getGraph().getLayout().getBounds()); }
private void handleSaveButton(GraphContainer graphContainer) { // Toggle save button for coordinates if (graphContainer.getLayoutAlgorithm() instanceof ManualLayoutAlgorithm) { // We only show the save button if we don't have a layout persisted, or the layout is not equal boolean showSave = layoutManager.loadLayout(graphContainer.getGraph()) == null || !layoutManager.isPersistedLayoutEqualToCurrentLayout(graphContainer.getGraph()); layerSaveButton.setEnabled(showSave); if (showSave) { layerSaveButton.setDescription("Save the current layout"); } else { layerSaveButton.setDescription("Nothing to save"); } } else { layerSaveButton.setEnabled(false); layerSaveButton.setDescription("Change to Manual Layout to enable saving"); } } }
@Override public void graphChanged(GraphContainer graphContainer) { if (!(graphContainer.getLayoutAlgorithm() instanceof ManualLayoutAlgorithm)) { LayoutEntity layoutEntity = layoutManager.loadLayout(graphContainer.getGraph()); if (layoutEntity != null) { boolean isEqualLayout = layoutManager.isPersistedLayoutEqualToCurrentLayout(graphContainer.getGraph()); getCompositionRoot().setVisible(!isEqualLayout); } else { getCompositionRoot().setVisible(false); } } else { getCompositionRoot().setVisible(false); } } }
@Override public void graphChanged(GraphContainer graphContainer) { if (!(graphContainer.getLayoutAlgorithm() instanceof ManualLayoutAlgorithm)) { LayoutEntity layoutEntity = layoutManager.loadLayout(graphContainer.getGraph()); if (layoutEntity != null) { boolean isEqualLayout = layoutManager.isPersistedLayoutEqualToCurrentLayout(graphContainer.getGraph()); getCompositionRoot().setVisible(!isEqualLayout); } else { getCompositionRoot().setVisible(false); } } else { getCompositionRoot().setVisible(false); } } }
private void handleSaveButton(GraphContainer graphContainer) { // Toggle save button for coordinates if (graphContainer.getLayoutAlgorithm() instanceof ManualLayoutAlgorithm) { // We only show the save button if we don't have a layout persisted, or the layout is not equal boolean showSave = layoutManager.loadLayout(graphContainer.getGraph()) == null || !layoutManager.isPersistedLayoutEqualToCurrentLayout(graphContainer.getGraph()); layerSaveButton.setEnabled(showSave); if (showSave) { layerSaveButton.setDescription("Save the current layout"); } else { layerSaveButton.setDescription("Nothing to save"); } } else { layerSaveButton.setEnabled(false); layerSaveButton.setDescription("Change to Manual Layout to enable saving"); } } }
@Override public void graphChanged(GraphContainer graphContainer) { final BreadcrumbCriteria criteria = Criteria.getSingleCriteriaForGraphContainer(graphContainer, BreadcrumbCriteria.class, true); final HorizontalLayout breadcrumbLayout = (HorizontalLayout) getCompositionRoot(); breadcrumbLayout.removeAllComponents(); // Verify that breadcrumbs are enabled if (graphContainer.getTopologyServiceClient().getBreadcrumbStrategy() == BreadcrumbStrategy.SHORTEST_PATH_TO_ROOT) { final Collection<Vertex> displayVertices = graphContainer.getGraph().getDisplayVertices(); if (!displayVertices.isEmpty()) { final PathTree pathTree = BreadcrumbPathCalculator.findPath(graphContainer.getTopologyServiceClient(), displayVertices.stream().map(v -> (VertexRef) v).collect(Collectors.toSet())); final List<Breadcrumb> breadcrumbs = pathTree.toBreadcrumbs(); criteria.setBreadcrumbs(breadcrumbs); } for (Breadcrumb eachBreadcrumb : criteria.getBreadcrumbs()) { if (breadcrumbLayout.getComponentCount() >= 1) { breadcrumbLayout.addComponent(new Label(" > ")); } breadcrumbLayout.addComponent(createButton(graphContainer, eachBreadcrumb)); } } }
public void apply(GraphContainer graphContainer, Collection<HistoryOperation> operations) { LOG.debug("Applying " + toString()); // Apply the history for each registered HistoryOperation for (HistoryOperation operation : operations) { try { operation.applyHistory(graphContainer, m_settings); } catch (Throwable e) { LOG.warn("Failed to perform applyHistory() operation", e); } } // Set Vertices in Focus after all other operations are applied, otherwise the topology provider may have changed // which results in a graphContainer.clearCriteria() applyVerticesInFocus(m_focusVertices, graphContainer); applySavedLocations(m_locations, graphContainer.getGraph().getLayout()); graphContainer.setSemanticZoomLevel(getSemanticZoomLevel()); graphContainer.getSelectionManager().setSelectedVertexRefs(m_selectedVertices); // Apply the selected vertices graphContainer.getMapViewManager().setBoundingBox(getBoundingBox()); }
public SavedHistory(GraphContainer graphContainer, Collection<HistoryOperation> operations) { this( graphContainer.getSemanticZoomLevel(), graphContainer.getMapViewManager().getCurrentBoundingBox(), saveLocations(graphContainer.getGraph()), getUnmodifiableSet(graphContainer.getSelectionManager().getSelectedVertexRefs()), getFocusVertices(graphContainer), getOperationSettings(graphContainer, operations) ); }
public SavedHistory(GraphContainer graphContainer, Collection<HistoryOperation> operations) { this( graphContainer.getSemanticZoomLevel(), graphContainer.getMapViewManager().getCurrentBoundingBox(), saveLocations(graphContainer.getGraph()), getUnmodifiableSet(graphContainer.getSelectionManager().getSelectedVertexRefs()), getFocusVertices(graphContainer), getOperationSettings(graphContainer, operations), getSearchQueries(graphContainer.getCriteria())); }
public SavedHistory(GraphContainer graphContainer, Collection<HistoryOperation> operations) { this( graphContainer.getSemanticZoomLevel(), graphContainer.getMapViewManager().getCurrentBoundingBox(), saveLocations(graphContainer.getGraph()), getUnmodifiableSet(graphContainer.getSelectionManager().getSelectedVertexRefs()), getFocusVertices(graphContainer), getOperationSettings(graphContainer, operations), getSearchQueries(graphContainer.getCriteria())); }
public TopologyComponent(GraphContainer dataSource, IconRepositoryManager iconRepositoryManager, ContextMenuHandler contextMenuHandler) { m_graphContainer = dataSource; m_iconRepoManager = iconRepositoryManager; m_contextMenuHandler = contextMenuHandler; registerRpc(m_rpc); setGraph(m_graphContainer.getGraph()); m_graphContainer.getSelectionManager().addSelectionListener(new SelectionListener() { @Override public void selectionChanged(SelectionContext selectionContext) { if (!m_blockSelectionEvents) { computeBoundsForSelected(selectionContext); } updateGraph(); } }); m_graphContainer.getMapViewManager().addListener(this); m_graphContainer.addChangeListener(this); setScaleDataSource(m_graphContainer.getScaleProperty()); getState().setSVGDefFiles(m_iconRepoManager.getSVGIconFiles()); updateGraph(); }