/** * Constructor. * * @param netPlan Network design * @since 0.3.0 */ public ForwardingRuleComparator(NetPlan netPlan) { this(netPlan, netPlan.getNetworkLayerDefault ().getId()); }
@Override public List<AjtColumnInfo<NetworkLayer>> getNonBasicUserDefinedColumnsVisibleOrNot() { final List<AjtColumnInfo<NetworkLayer>> res = new LinkedList<> (); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Name", "Layer name", (d,val)->d.setName((String)val) , d->d.getName() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Description", "Layer description", (d,val)->d.setDescription((String)val) , d->d.getDescription() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Link capacity units", "Name of the capacity units of the links", (d,val)->d.getNetPlan().setLinkCapacityUnitsName((String)val, d) , d->d.getLinkCapacityUnits() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Demand traffic units", "Name of the traffic units of the demands", (d,val)->d.getNetPlan().setDemandTrafficUnitsName((String)val, d) , d->d.getDemandTrafficUnits() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# links", "Number of links", null , d->d.getNetPlan().getNumberOfLinks(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# demands", "Number of demands", null , d->d.getNetPlan().getNumberOfDemands(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# multicast demands", "Number of multicast demands", null , d->d.getNetPlan().getNumberOfMulticastDemands(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# routes", "Number of routes", null , d->d.getNetPlan().getNumberOfRoutes(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# forw. rules", "Number of forwarding rules", null , d->d.getNetPlan().getNumberOfForwardingRules(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# multicast trees", "Number of multicast trees", null , d->d.getNetPlan().getNumberOfMulticastTrees(d) , AGTYPE.NOAGGREGATION , null)); return res; }
public Icon getIcon() { URL url = npNode.getUrlNodeIcon(layer); if (url == null) url = layer.getDefaultNodeIconURL(); if (url == null) url = VisualizationConstants.DEFAULT_LAYERNAME2ICONURLMAP.get(layer.getName()); final int height = layer.isDefaultLayer() ? (int) (iconHeightIfNotActive * VisualizationConstants.INCREASENODESIZEFACTORACTIVE) : (int) iconHeightIfNotActive; final Color borderColor = getBorderPaint() == VisualizationConstants.DEFAULT_GUINODE_COLOR ? VisualizationConstants.TRANSPARENTCOLOR : (Color) getBorderPaint(); final Icon icon = VisualizationState.getIcon(url, height, borderColor).getFirst(); return icon; }
NetworkLayer thisLayer = getNetworkLayerFromId (otherLayer .getId()); if (thisLayer != null) if (!thisLayer.getName().equals(otherLayer.getName())) throw new Net2PlanException ("Layer mismatch. Output may be corrupted"); if (thisLayer == null) thisLayer = addLayer(otherLayer.getName(), "", otherDesign.getLinkCapacityUnitsName(otherLayer), otherDesign.getDemandTrafficUnitsName(otherLayer), null, null); thisLayer.setDescription(otherLayer.getDescription()); thisLayer.setName(otherLayer.getName()); thisLayer.setDefaultNodeIconURL(otherLayer.getDefaultNodeIconURL()); thisLayer.setAttributeMap(otherLayer.getAttributes()); // previous attributes are not removed, just new added or existing updated for (String tag : otherLayer.getTags()) thisLayer.addTag(tag);
private List<Triple<String,String,String>> getLayerInfoTables (NetworkLayer layer) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = layer.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String capUnits = np.getLinkCapacityUnitsName(layer); final String trafUnits = np.getDemandTrafficUnitsName(layer); res.add(Triple.of("Layer index/id" , "Layer " + layer.getIndex() + " (id " + layer.getId() + ")", "layer" + layer.getId())); res.add(Triple.of("Name" , layer.getName().equals("")? "No name" : layer.getName(), "")); res.add(Triple.of("Description" , layer.getDescription().equals("")? "No description" : layer.getDescription(), "")); res.add(Triple.of("Demand traffic units" , trafUnits.equals("")? "Not specified" : trafUnits, "")); res.add(Triple.of("Link capacity units" , capUnits.equals("")? "Not specified" : capUnits, "")); final double totalOccupiedCap = np.getLinks(layer).stream().mapToDouble(e->e.getOccupiedCapacity()).sum(); final double totalCap = np.getLinks(layer).stream().mapToDouble(e->e.getCapacity()).sum(); final double totalOfferedTrac = np.getDemands(layer).stream().mapToDouble(e->e.getOfferedTraffic()).sum(); final double totalCarriedTrac = np.getDemands(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum(); final double totalOffMultTraffic = np.getMulticastDemands(layer).stream().mapToDouble(e->e.getOfferedTraffic()).sum(); final double totalCarMultTraffic = np.getMulticastDemands(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum(); res.add(Triple.of("# links (total occupied / capacity)", "" + np.getNumberOfLinks(layer) + " (" + df.format(totalOccupiedCap) + " / " + df.format(totalCap) + ") " + capUnits + ")" , "")); res.add(Triple.of("# demands (total carried / offered)", "" + np.getNumberOfDemands(layer) + " (" + df.format(totalCarriedTrac) + " / " + df.format(totalOfferedTrac) + ") " + trafUnits, "")); res.add(Triple.of("# routes", "" + np.getNumberOfRoutes(layer) , "")); res.add(Triple.of("# forwarding rules", "" + np.getNumberOfForwardingRules(layer) , "")); res.add(Triple.of("# multicast demands (total carried / offered)", "" + np.getNumberOfMulticastDemands(layer) + " (" + df.format(totalCarMultTraffic) + " / " + df.format(totalOffMultTraffic) + ") " + trafUnits, "")); res.add(Triple.of("# multicast trees", "" + np.getNumberOfMulticastTrees(layer) , "")); return res; } private List<Triple<String,String,String>> getNodeInfoTables (Node n , NetworkLayer layer)
Map<String, String> layerAttributes = layer.getAttributes(); if (!layerAttributes.isEmpty()) final Set<String> layerTags = layer.getTags(); final String[] tagArray = layerTags.toArray(new String[layerTags.size()]); if (!txt_layerName.getText().equals(layer.getName())) txt_layerName.setText(layer.getName()); if (!txt_layerDescription.getText().equals(layer.getDescription())) txt_layerDescription.setText(layer.getDescription()); if (!txt_layerLinkCapacityUnits.getText().equals(currentState.getLinkCapacityUnitsName(layerThisTable))) txt_layerLinkCapacityUnits.setText(currentState.getLinkCapacityUnitsName(layerThisTable));
public void put(Demand demand , Link link) { demandLinkMapping.put(demand, link); if (demandSideLayer == null) demandSideLayer = demand.layer; else if (!demandSideLayer.equals(demand.layer)) throw new RuntimeException ("Bad"); if (linkSideLayer == null) linkSideLayer = link.layer; else if (!linkSideLayer.equals(link.layer)) throw new RuntimeException ("Bad"); }
if (nodeAndLayerToIconURLMap.containsKey(newLayer.getId())) for (Pair<Node,URL> iconInfo : nodeAndLayerToIconURLMap.get(newLayer.getId())) iconInfo.getFirst().setUrlNodeIcon(newLayer , iconInfo.getSecond() , 1.0); newLayer.addTag(xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"))); break; newLayer.setAttribute(getString ("key"), getString ("value")); break;
wdmLayer.setName("WDM"); netPlan.setRoutingTypeAllDemands(Constants.RoutingType.SOURCE_ROUTING, wdmLayer); ipLayer.setName("IP"); netPlan.setRoutingTypeAllDemands(Constants.RoutingType.HOP_BY_HOP_ROUTING, ipLayer); netPlan.setNetworkLayerDefault(wdmLayer); cpl.removeNetworkLayer(cpl.getNetworkLayerFromId(ipLayer.getId())); for (Node n1 : cpl.getNodes()) for (Node n2 : cpl.getNodes()) if (n1 != n2) cpl.addDemand(n1, n2, 0.0, RoutingType.SOURCE_ROUTING , null); cpl.addRoutesFromCandidatePathList(cpl.computeUnicastCandidatePathList(null , K, -1, -1, -1, -1, -1, -1 , null)); final NetworkLayer ipLayer_thisFailure = netPlan_thisFailure.getNetworkLayer(ipLayer.getIndex()); final SharedRiskGroup thisNp_srg = netPlan_thisFailure.getSRG(srg.getIndex()); thisNp_srg.setAsDown();
public List<?> getVisibleElements (NetworkLayer layer , AJTableType type) { switch (type.getNeType()) { case DEMAND: return vDemands.get(layer); case FORWARDING_RULE: return vFRs.get(layer); case LAYER: return layer.getNetPlan().getNetworkLayers(); case LINK: return vLinks.get(layer); case MULTICAST_DEMAND: return vMDemands.get(layer); case MULTICAST_TREE: return vTrees.get(layer); case NETWORK: return null; case NODE: return vNodes.get(layer); case RESOURCE: return vResources.get(layer); case ROUTE: return vRoutes.get(layer); case SRG: return vSRGs.get(layer); default: throw new RuntimeException(); } }
final List<Long> idsLayersWithIcons = layersWithIcons.stream().map(l -> l.getId()).collect(Collectors.toList()); writer.writeAttribute("layersWithIconsDefined", CollectionUtils.join(idsLayersWithIcons, " ")); for (NetworkLayer layer : layersWithIcons) if (node.getUrlNodeIcon(layer) != null) writer.writeAttribute("nodeIconURLLayer_" + layer.getId(), node.getUrlNodeIcon(layer).toString()); writer.writeAttribute("nodeIconRelativeSizeLayer_" + layer.getId(), "" + node.getNodeIconRelativeSize(layer)); writer.writeAttribute("description", layer.getDescription()); writer.writeAttribute("name", layer.getName()); writer.writeAttribute("isDefaultLayer", Boolean.toString(defaultLayer == layer)); writer.writeAttribute("linkCapacityUnitsName", layer.linkCapacityUnitsName);
final String layerName = layer.getName().replaceAll(" ", ""); final String buttonText = layerName.isEmpty() || layerName.contains("Layer") ? "LAY" + layer.getIndex() : (layerName.length() <= 4 ? layerName : layerName.substring(0, 4)); final JButton layerButton = new JButton(); layerButton.setOpaque(false); final Font buttonFont; if (layer.isDefaultLayer())
"", this, Arrays.asList(InputForDialog.inputTfDouble("Offered traffic (" + getTableNetworkLayer().getDemandTrafficUnits() + ")", "Introduce the offered traffic", 10, 0.0)), (list)-> for (long layerId : layerIds) if (layerId == getTableNetworkLayer().getId()) continue; final String layerName = np.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")";
for (long layerId : layerIds) final String layerName = np.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; for (long layerId : layerIds) if (layerId == this.getTableNetworkLayer().getId()) continue; final String layerName = np.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; "", this, Arrays.asList(InputForDialog.inputTfDouble("Link capacity (" + getTableNetworkLayer().getLinkCapacityUnits() + ")", "Introduce the link capacity", 10, 0.0)), (list)->
public GUILayer(final NetworkLayer layer) { this.associatedNetworkLayer = layer; this.isLayerVisible = true; this.isLinksVisible = true; this.layerOrder = layer.getIndex(); }
NetworkLayer newLayer = new NetworkLayer(this, originLayer.id, originLayer.index, originLayer.demandTrafficUnitsName, originLayer.description, originLayer.name, originLayer.linkCapacityUnitsName, originLayer.defaultNodeIconURL, originLayer.attributes); for (String tag : originLayer.getTags ()) newLayer.addTag (tag); cache_id2LayerMap.put(originLayer.id, newLayer); layers.add(newLayer); newResource.copyFrom(originNetPlan.resources.get(newResource.index)); for (SharedRiskGroup newSrg : this.srgs) newSrg.copyFrom(originNetPlan.srgs.get(newSrg.index)); for (NetworkLayer newLayer : this.layers) newLayer.copyFrom(originNetPlan.layers.get(newLayer.index));
private Pair<ImageIcon,Shape> getNodeIcon (Node n , NetworkLayer layer , int maxHeightOrSizeIcon) { URL url = n.getUrlNodeIcon(layer); if (url == null) url = layer.getDefaultNodeIconURL(); if (url == null) url = DEFAULT_LAYERNAME2ICONURLMAP.get(layer.getName()); Pair<ImageIcon,Shape> pair = VisualizationState.getIcon(url , maxHeightOrSizeIcon , VisualizationConstants.TRANSPARENTCOLOR); if (pair.getFirst().getIconWidth() > maxHeightOrSizeIcon) { final int newHeight = maxHeightOrSizeIcon * (pair.getFirst().getIconWidth() / maxHeightOrSizeIcon); pair = VisualizationState.getIcon(url , newHeight , VisualizationConstants.TRANSPARENTCOLOR); } return pair; } private Pair<ImageIcon,Shape> getResourceIcon (Resource r , int maxHeightOrSizeIcon)
NetworkLayer(NetPlan netPlan, long id, int index , String demandTrafficUnitsName, String description, String name, String linkCapacityUnitsName, URL defaultNodeIconURL , AttributeMap attributes) this.setName ("Layer-" + index);