public Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> suggestCanvasUpdatedVisualizationLayerInfoForNewDesign(Set<NetworkLayer> newNetworkLayers) { final Map<NetworkLayer, Boolean> oldLayerVisibilityMap = getCanvasLayerVisibilityMap(); final BidiMap<NetworkLayer, Integer> oldLayerOrderMap = new DualHashBidiMap<>(getCanvasLayerOrderIndexMap(true)); final Map<NetworkLayer, Boolean> newLayerVisibilityMap = new HashMap<>(); final BidiMap<NetworkLayer, Integer> newLayerOrderMap = new DualHashBidiMap<>(); for (int oldVisibilityOrderIndex = 0; oldVisibilityOrderIndex < oldLayerOrderMap.size(); oldVisibilityOrderIndex++) { final NetworkLayer oldLayer = oldLayerOrderMap.inverseBidiMap().get(oldVisibilityOrderIndex); if (newNetworkLayers.contains(oldLayer)) { newLayerOrderMap.put(oldLayer, newLayerVisibilityMap.size()); newLayerVisibilityMap.put(oldLayer, oldLayerVisibilityMap.get(oldLayer)); } } final Set<NetworkLayer> newLayersNotExistingBefore = Sets.difference(newNetworkLayers, oldLayerVisibilityMap.keySet()); for (NetworkLayer newLayer : newLayersNotExistingBefore) { newLayerOrderMap.put(newLayer, newLayerVisibilityMap.size()); newLayerVisibilityMap.put(newLayer, true); // new layers always visible } return Pair.of(newLayerOrderMap, newLayerVisibilityMap); }
protected static String getType(Class<?> clazz) { if (classMap.containsValue(clazz)) { return classMap.getKey(clazz); } else { return clazz.getCanonicalName().toString(); } }
protected Class<?> getClass(String name) throws ClassNotFoundException { if (classMap.containsKey(name)) { return classMap.get(name); } else { return Class.forName(name); } }
/** * Under testing, do not use just yet **/ public T getElementAtModelRowIndex(int rowModelIndex) { return this.mapElementId2ModelIndexWithThatValue.inverseBidiMap().get(rowModelIndex); }
public int getCanvasVisualizationOrderRemovingNonVisible(NetworkLayer layer) { Integer res = cache_mapCanvasVisibleLayer2VisualizationOrderRemovingNonVisible.get(layer); if (res == null) throw new RuntimeException(""); return res; }
final BidiMap<Node,Integer> cand_a = createBidiMap(getCandidateDistributionCenters(netPlan)); final BidiMap<Node,Integer> cand_d = createBidiMap(getCandidateDestinations(netPlan)); final int NUM_O = cand_o.size(); final int NUM_A = cand_a.size(); final int NUM_D = cand_d.size(); for (Node orig : cand_o.keySet()) for (Node dest : cand_d.keySet()) if (!forbidRoutesNotTraversingADistributionCenter.getBoolean()) netPlan.addRoute(d, 0.0, 0.0, Arrays.asList (getLink(orig, dest)), null); for (Node dc : cand_a.keySet()) netPlan.addRoute(d, 0.0, 0.0, Arrays.asList (getLink (orig , dc) , getLink(dc , dest)), null); final int oIndex = cand_o.get(o); final int dIndex = cand_d.get(d); if (r.getSeqLinks().size() > 1) final int aIndex = cand_a.get(a); A_ap.set(aIndex , r.getIndex() , 1.0); final double [] y_a_min = new double [NUM_A]; for (int cont = 0 ; cont < NUM_A ; cont ++) y_a_min [cont] = Math.max(0 , (double) getMinNumDistributionCentersInLocation(cand_a.inverseBidiMap().get(cont) , 0)); final double [] y_a_max = new double [NUM_A]; for (int cont = 0 ; cont < NUM_A ; cont ++) y_a_max [cont] = Math.max(0 , (double) getMaxNumDistributionCentersInLocation(cand_a.inverseBidiMap().get(cont) , 0)); final double [] y_o_min = new double [NUM_O]; for (int cont = 0 ; cont < NUM_O ; cont ++) y_o_min [cont] = Math.max(0 , (double) getMinNumPlantsInLocation(cand_o.inverseBidiMap().get(cont) , 0)); final double [] y_o_max = new double [NUM_O]; for (int cont = 0 ; cont < NUM_O ; cont ++) y_o_max [cont] = Math.max(0 , (double) getMaxNumPlantsInLocation(cand_o.inverseBidiMap().get(cont) , 0)); final double [] h_dest = new double [NUM_D]; for (int cont = 0 ; cont < NUM_D ; cont ++) h_dest [cont] = Math.max(0, getDemandSize(cand_d.inverseBidiMap().get(cont) , 0.0)); final double [] minHDestAndMaxBlockedGoods_dest = new double [NUM_D]; for (int cont = 0 ; cont < NUM_D ; cont ++) minHDestAndMaxBlockedGoods_dest [cont] = Math.max(0, Math.min(h_dest [cont] , getMaxBlockedGoods(cand_d.inverseBidiMap().get(cont) , 0.0))); final double [] maxTraffic_p = new double [P]; for (int cont = 0 ; cont < P ; cont ++) maxTraffic_p [cont] = maxDistanceOriginToDestinationInKm.getDouble() > 0? (netPlan.getRoute(cont).getLengthInKm() > maxDistanceOriginToDestinationInKm.getDouble()? 0.0 : Double.MAX_VALUE ) : Double.MAX_VALUE;
tag_state.put("node", TagState.VERTEX); tag_state.put("edge", TagState.EDGE); tag_state.put("hyperedge", TagState.HYPEREDGE); tag_state.put("endpoint", TagState.ENDPOINT); tag_state.put("graph", TagState.GRAPH); tag_state.put("data", TagState.DATA); tag_state.put("key", TagState.KEY); tag_state.put("desc", TagState.DESC); tag_state.put("default", TagState.DEFAULT_KEY); tag_state.put("graphml", TagState.GRAPHML);
nodesToDnMap.put(tree.getIngressNode(), ingressDn); for (int numHops = 1; numHops <= maxNumberOfHops; numHops++) List<Link> sortedListUpToDown = linksThisHopIndex.stream().sorted(Comparator.comparingInt(e1 -> nodesToDnMap.get(e1.getOriginNode()).getPosTopLeftCornerToSetByPainter().y)).collect(Collectors.toList()); for (Link e : sortedListUpToDown) this.drawnNodes.add(dn); DrawNode.addNodeToGraphics(g2d, dn, dnTopLeftPosition, fontMetrics, regularInterlineSpacePixels, tree.getEgressNodesReached().contains(n) ? Color.CYAN : null); nodesToDnMap.put(n, dn); yPositionTopDn += spaceBetweenVerticalNodes; final DrawNode dnOrigin = nodesToDnMap.get(e.getOriginNode()); final DrawLine dlLink = new DrawLine(dnOrigin, dn, e, dnOrigin.posEast(), dn.posWest(), tree.getOccupiedLinkCapacity()); DrawLine.addLineToGraphics(g2d, dlLink, fontMetrics, regularInterlineSpacePixels);
private Object[][] computeDataVector (List<AjtColumnInfo<T>> visibleTableColumns, boolean allCollumns) this.mapElementId2ModelIndexWithThatValue.clear(); assert !this.mapElementId2ModelIndexWithThatValue.containsKey(visibleElement); assert !this.mapElementId2ModelIndexWithThatValue.containsValue(rowCount); this.mapElementId2ModelIndexWithThatValue.put(visibleElement, rowCount); rowCount ++;
@SuppressWarnings("unchecked") protected void createVertex(Attributes atts) throws SAXNotSupportedException { Map<String, String> vertex_atts = getAttributeMap(atts); String id = vertex_atts.remove("id"); if (id == null) throw new SAXNotSupportedException("node attribute list missing " + "'id': " + atts.toString()); V v = vertex_ids.getKey(id); if (v == null) { if (vertex_factory != null) v = vertex_factory.create(); else v = (V)id; vertex_ids.put(v, id); this.current_graph.addVertex(v); // put remaining attribute/value pairs in vertex_data addExtraData(vertex_atts, vertex_metadata, v); } else throw new SAXNotSupportedException("Node id \"" + id + " is a duplicate of an existing node ID"); this.current_vertex = v; }
final int defaultLayerIndex = layerOrderMapConsideringNonVisible.get(defaultLayer); final NetworkLayer neighbourLayer = layerOrderMapConsideringNonVisible.inverseBidiMap().get(defaultLayerIndex - 1); final int defaultLayerIndex = layerOrderMapConsideringNonVisible.get(defaultLayer); if (defaultLayerIndex == layerOrderMapConsideringNonVisible.size() - 1) return; final NetworkLayer neighbourLayer = layerOrderMapConsideringNonVisible.inverseBidiMap().get(defaultLayerIndex + 1);
@SuppressWarnings("unchecked") protected void createEdge(Attributes atts, TagState state) throws SAXNotSupportedException { Map<String,String> edge_atts = getAttributeMap(atts); String id = edge_atts.remove("id"); E e; if (edge_factory != null) e = edge_factory.create(); else if (id != null) e = (E)id; else throw new IllegalArgumentException("If no edge factory is supplied, " + "edge id may not be null: " + edge_atts); if (id != null) { if (edge_ids.containsKey(e)) throw new SAXNotSupportedException("Edge id \"" + id + "\" is a duplicate of an existing edge ID"); edge_ids.put(e, id); } if (state == TagState.EDGE) assignEdgeSourceTarget(e, atts, edge_atts); //, id); // put remaining attribute/value pairs in edge_data addExtraData(edge_atts, edge_metadata, e); this.current_edge = e; }
public void stateChanged(ChangeEvent e) { for(V v : vertexMap.keySet()) { Point3f p = VisualizationViewer.this.layout.transform(v); Vector3f pv = new Vector3f(p.getX(), p.getY(), p.getZ()); Transform3D tx = new Transform3D(); tx.setTranslation(pv); vertexMap.get(v).setTransform(tx); } for(E edge : graph.getEdges()) { Pair<V> endpoints = graph.getEndpoints(edge); V start = endpoints.getFirst(); V end = endpoints.getSecond(); EdgeGroup eg = edgeMap.get(edge); eg.setEndpoints(layout.transform(start), layout.transform(end)); } }});
throw new SAXNotSupportedException("edge attribute list missing " + "'source': " + atts.toString()); V source = vertex_ids.getKey(source_id); if (source == null) throw new SAXNotSupportedException("specified 'source' attribute " + throw new SAXNotSupportedException("edge attribute list missing " + "'target': " + atts.toString()); V target = vertex_ids.getKey(target_id); if (target == null) throw new SAXNotSupportedException("specified 'target' attribute " +
public List<NetworkLayer> getCanvasLayersInVisualizationOrder(boolean includeNonVisible) { Map<Integer, NetworkLayer> map = includeNonVisible ? MapUtils.invertMap(visualizationSnapshot.getMapCanvasLayerVisualizationOrder()) : cache_mapCanvasVisibleLayer2VisualizationOrderRemovingNonVisible.inverseBidiMap(); List<NetworkLayer> res = new ArrayList<>(); for (int vIndex = 0; vIndex < this.getNetPlan().getNumberOfLayers(); vIndex++) res.add(map.get(vIndex)); return res; }
public NetworkLayer getCanvasNetworkLayerAtVisualizationOrderRemovingNonVisible(int trueVisualizationOrder) { if (trueVisualizationOrder < 0) throw new RuntimeException(""); if (trueVisualizationOrder >= getCanvasNumberOfVisibleLayers()) throw new RuntimeException(""); return cache_mapCanvasVisibleLayer2VisualizationOrderRemovingNonVisible.inverseBidiMap().get(trueVisualizationOrder); }
/** * Under testing, do not use just yet **/ public Optional<Integer> getRowModelIndexOfElement(Object element) { final Integer res = this.mapElementId2ModelIndexWithThatValue.get(element); return res == null? Optional.empty() : Optional.of(res); }