当前位置: 首页>>代码示例>>Java>>正文


Java BidiMap类代码示例

本文整理汇总了Java中org.apache.commons.collections15.BidiMap的典型用法代码示例。如果您正苦于以下问题:Java BidiMap类的具体用法?Java BidiMap怎么用?Java BidiMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BidiMap类属于org.apache.commons.collections15包,在下文中一共展示了BidiMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executionFinished

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
@Override
public void executionFinished(ThreadExecutionController controller, Object out) 
{
       try {
           double execTime = (System.nanoTime() - start) / 1e9;
           final VisualizationState vs = mainWindow.getVisualizationState();
           final NetPlan netPlan = mainWindow.getDesign();
   		Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer,Boolean>> res = 
   				vs.suggestCanvasUpdatedVisualizationLayerInfoForNewDesign(new HashSet<> (netPlan.getNetworkLayers()));
   		vs.setCanvasLayerVisibilityAndOrder(netPlan, res.getFirst() , res.getSecond());
           mainWindow.updateVisualizationAfterNewTopology();
           mainWindow.addNetPlanChange();
           String outMessage = String.format("Algorithm executed successfully%nExecution time: %.3g s%nExit message: %s", execTime, out);
           JOptionPane.showMessageDialog(null, outMessage, "Solve design", JOptionPane.PLAIN_MESSAGE);
       } catch (Throwable ex) {
           ErrorHandling.addErrorOrException(ex, OfflineExecutionPanel.class);
           ErrorHandling.showErrorDialog("Error executing algorithm");
       }
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:20,代码来源:OfflineExecutionPanel.java

示例2: suggestCanvasUpdatedVisualizationLayerInfoForNewDesign

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
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);
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:24,代码来源:VisualizationState.java

示例3: modifyEntrySet

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
private final void modifyEntrySet(BidiMap map) {
    // Gets first entry
    final Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();

    // Gets key and value
    final Object key = entry.getKey();
    final Object oldValue = entry.getValue();

    // Sets new value
    final Object newValue = "newValue";
    entry.setValue(newValue);

    assertEquals("Modifying entrySet did not affect underlying Map.", newValue, map.get(key));

    assertNull("Modifying entrySet did not affect inverse Map.", map.getKey(oldValue));
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:17,代码来源:AbstractTestBidiMap.java

示例4: testBidiClear

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public void testBidiClear() {
    if (isRemoveSupported() == false) {
        try {
            makeFullBidiMap().clear();
            fail();
        } catch (UnsupportedOperationException ex) {
        }
        return;
    }

    BidiMap map = makeFullBidiMap();
    map.clear();
    assertTrue("Map was not cleared.", map.isEmpty());
    assertTrue("Inverse map was not cleared.", map.inverseBidiMap().isEmpty());

    // Tests clear on inverse
    map = makeFullBidiMap().inverseBidiMap();
    map.clear();
    assertTrue("Map was not cleared.", map.isEmpty());
    assertTrue("Inverse map was not cleared.", map.inverseBidiMap().isEmpty());

}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:23,代码来源:AbstractTestBidiMap.java

示例5: graphToSparseMatrix

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
/**
 * Returns a SparseDoubleMatrix2D whose entries represent the edge weights for the
 * edges in <code>g</code>, as specified by <code>nev</code>.  
 * 
 * <p>The <code>(i,j)</code> entry of the matrix returned will be equal to the sum
 * of the weights of the edges connecting the vertex with index <code>i</code> to 
 * <code>j</code>.
 * 
 * <p>If <code>nev</code> is <code>null</code>, then a constant edge weight of 1 is used.
 * 
 * @param g
 * @param nev
 */
public static <V,E> SparseDoubleMatrix2D graphToSparseMatrix(Graph<V,E> g, Map<E,Number> nev)
{
    if (nev == null)
        nev = new ConstantMap<E,Number>(1);
    int numVertices = g.getVertexCount();
    SparseDoubleMatrix2D matrix = new SparseDoubleMatrix2D(numVertices,
            numVertices);

    BidiMap<V,Integer> indexer = Indexer.<V>create(g.getVertices());
    int i=0;
    
    for(V v : g.getVertices())
    {
        for (E e : g.getOutEdges(v))
        {
            V w = g.getOpposite(v,e);
            int j = indexer.get(w);
            matrix.set(i, j, matrix.getQuick(i,j) + nev.get(e).doubleValue());
        }
        i++;
    }
    return matrix;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:37,代码来源:GraphMatrixOperations.java

示例6: getEnumAliases

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
/**
 * Return the enum aliases map.
 *
 * @return the enum aliases map
 */
public BidiMap<String, Class<? extends Enum<?>>> getEnumAliases()
{
	// using the double-checked locking with volatile
	// @see http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
	if (enumAliases == null)
	{
		synchronized (this)
		{
			if (enumAliases == null)
			{
				enumAliases = initializeEnumAliases();
			}
		}
	}
	// Defensive copy. TODO: move to CollectionUtil as a generic factory method
	return new DualHashBidiMap<>(enumAliases);
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:23,代码来源:EnumAliasService.java

示例7: read

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public void read(Graph<V,E> graph, String file, Factory<V> vf, Factory<E> ef) throws ParserConfigurationException, SAXException, IOException{
  //Step 1 we make a new GraphML Reader. We want an Undirected Graph of type node and edge.
    GraphMLReader<Graph<V,E>, V,E> gmlr = new GraphMLReader<Graph<V,E>, V,E>(vf, ef);
     
    //Here we read in our graph. filename is our .graphml file, and graph is where we will store our graph.
    gmlr.load(file, graph);
    
    BidiMap<V, String> vertex_ids = gmlr.getVertexIDs();  //The vertexIDs are stored in a BidiMap.
    Map<String, GraphMLMetadata<V>> vertex_color = gmlr.getVertexMetadata(); //Our vertex Metadata is stored in a map.
    Map<String, GraphMLMetadata<E>> edge_meta = gmlr.getEdgeMetadata(); // Our edge Metadata is stored in a map.
     
    // Here we iterate through our vertices, n, and we set the value and the color of our nodes from the data we have
    // in the vertex_ids map and vertex_color map.
    for (V n : graph.getVertices())
    {
        //n.setValue(vertex_ids.get(n)); //Set the value of the node to the vertex_id which was read in from the GraphML Reader.
        //n.setColor(vertex_color.get("d0").transformer.transform(n)); // Set the color, which we get from the Map vertex_color.            //Let's print out the data so we can get a good understanding of what we've got going on.
        //System.out.println("ID: "+n.getID()+", Value: "+n.getValue()+", Color: "+n.getColor());
    }
     // Just as we added the vertices to the graph, we add the edges as well.
    for (E e : graph.getEdges())
    {
        //e.setValue(edge_meta.get("d1").transformer.transform(e)); //Set the edge's value.
        //System.out.println("Edge ID: "+e.getID());
    }
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:27,代码来源:GraphMLReadWrite.java

示例8: resetButton

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
private void resetButton()
    {
        try
        {
            final int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to reset? This will remove all unsaved data", "Reset", JOptionPane.YES_NO_OPTION);
            if (result != JOptionPane.YES_OPTION) return;

            if (inOnlineSimulationMode())
            {
                switch (onlineSimulationPane.getSimKernel().getSimCore().getSimulationState())
                {
                    case NOT_STARTED:
                    case STOPPED:
                        break;
                    default:
                        onlineSimulationPane.getSimKernel().getSimCore().setSimulationState(SimState.STOPPED);
                        break;
                }
                onlineSimulationPane.getSimKernel().reset();
                setDesign(onlineSimulationPane.getSimKernel().getCurrentNetPlan());
            } else
            {
                setDesign(new NetPlan());
                //algorithmSelector.reset();
                executionPane.reset();
            }
//            reportSelector.reset();
//            reportContainer.removeAll();
        } catch (Throwable ex)
        {
            ErrorHandling.addErrorOrException(ex, GUINetworkDesign.class);
            ErrorHandling.showErrorDialog("Unable to reset");
        }
        Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = VisualizationState.generateCanvasDefaultVisualizationLayerInfo(getDesign());
        vs.setCanvasLayerVisibilityAndOrder(getDesign(), res.getFirst(), res.getSecond());
        updateVisualizationAfterNewTopology();
        undoRedoManager.addNetPlanChange();
    }
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:39,代码来源:GUINetworkDesign.java

示例9: getAddOption

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
@Override
protected JMenuItem getAddOption()
{
    JMenuItem addItem = new JMenuItem("Add " + networkElementType);

    addItem.addActionListener(new ActionListener()
    {
        @Override
        public void actionPerformed(ActionEvent e)
        {
            NetPlan netPlan = callback.getDesign();

            try
            {
                netPlan.addLayer("Layer " + netPlan.getNumberOfLayers(), null, null, null, null, null);
                final VisualizationState vs = callback.getVisualizationState();
                Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = vs.suggestCanvasUpdatedVisualizationLayerInfoForNewDesign(new HashSet<>(callback.getDesign().getNetworkLayers()));
                vs.setCanvasLayerVisibilityAndOrder(callback.getDesign(), res.getFirst(), res.getSecond());
                callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LAYER));
                callback.addNetPlanChange();
            } catch (Throwable ex)
            {
                ex.printStackTrace();
                ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to add " + networkElementType);
            }
        }
    });

    return addItem;
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:31,代码来源:AdvancedJTable_layer.java

示例10: VisualizationState

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public VisualizationState(NetPlan currentNp, BidiMap<NetworkLayer, Integer> mapLayer2VisualizationOrder, Map<NetworkLayer, Boolean> layerVisibilityMap, int maxSizePickUndoList)
{
    this.visualizationSnapshot = new VisualizationSnapshot(currentNp);
    this.showInCanvasNodeNames = false;
    this.showInCanvasLinkLabels = false;
    this.showInCanvasLinksInNonActiveLayer = true;
    this.showInCanvasInterLayerLinks = true;
    this.showInCanvasNonConnectedNodes = true;
    this.showInCanvasLowerLayerPropagation = true;
    this.showInCanvasUpperLayerPropagation = true;
    this.showInCanvasThisLayerPropagation = true;
    this.whatIfAnalysisActive = false;
    this.nodesToHideInCanvasAsMandatedByUserInTable = new HashSet<>();
    this.linksToHideInCanvasAsMandatedByUserInTable = new HashSet<>();
    this.interLayerSpaceInPixels = 50;
    this.tableRowFilter = null;
    this.linkUtilizationColorThresholdList = new ArrayList<> (VisualizationConstants.DEFAULT_LINKCOLORINGUTILIZATIONTHRESHOLDS);
    this.linkCapacityThicknessThresholdList = new ArrayList<> (VisualizationConstants.DEFAULT_LINKTHICKNESSTHRESHPOLDS);
    this.linkRunoutTimeColorThresholdList = new ArrayList<> (VisualizationConstants.DEFAULT_LINKCOLORINGRUNOUTTHRESHOLDS);
    this.isActiveLinkUtilizationColorThresholdList = true;
    this.isActiveLinkRunoutTimeColorThresholdList = false;
    this.isActiveLinkCapacityThicknessThresholdList = true;

    this.linkWidthIncreaseFactorRespectToDefault = 1;
    this.nodeSizeFactorRespectToDefault = 1;

    this.pickManager = new PickManager(this);

    this.setCanvasLayerVisibilityAndOrder(currentNp, mapLayer2VisualizationOrder, layerVisibilityMap);
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:31,代码来源:VisualizationState.java

示例11: setCanvasLayerVisibility

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public void setCanvasLayerVisibility(final NetworkLayer layer, final boolean isVisible)
{
    if (!this.getNetPlan().getNetworkLayers().contains(layer)) throw new RuntimeException();
    BidiMap<NetworkLayer, Integer> new_layerVisiblityOrderMap = new DualHashBidiMap<>(this.visualizationSnapshot.getMapCanvasLayerVisualizationOrder());
    Map<NetworkLayer, Boolean> new_layerVisibilityMap = new HashMap<>(this.visualizationSnapshot.getMapCanvasLayerVisibility());
    new_layerVisibilityMap.put(layer, isVisible);
    setCanvasLayerVisibilityAndOrder(this.getNetPlan(), new_layerVisiblityOrderMap, new_layerVisibilityMap);
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:9,代码来源:VisualizationState.java

示例12: generateCanvasDefaultVisualizationLayerInfo

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public static Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> generateCanvasDefaultVisualizationLayerInfo(NetPlan np)
{
    final BidiMap<NetworkLayer, Integer> res_1 = new DualHashBidiMap<>();
    final Map<NetworkLayer, Boolean> res_2 = new HashMap<>();

    for (NetworkLayer layer : np.getNetworkLayers())
    {
        res_1.put(layer, res_1.size());
        res_2.put(layer, true);
    }
    return Pair.of(res_1, res_2);
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:13,代码来源:VisualizationState.java

示例13: inverseBidiMap

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public BidiMap<V, K> inverseBidiMap() {
    if (inverse == null) {
        inverse = new UnmodifiableBidiMap<V, K>(getBidiMap().inverseBidiMap());
        inverse.inverse = this;
    }
    return inverse;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:8,代码来源:UnmodifiableBidiMap.java

示例14: testDecorateFactory

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public void testDecorateFactory() {
    MapIterator it = makeFullMapIterator();
    assertSame(it, UnmodifiableMapIterator.decorate(it));

    it = ((BidiMap) getMap()).mapIterator();
    assertTrue(it != UnmodifiableMapIterator.decorate(it));

    try {
        UnmodifiableMapIterator.decorate(null);
        fail();
    } catch (IllegalArgumentException ex) {
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:14,代码来源:TestUnmodifiableMapIterator.java

示例15: makeFullBidiMap

import org.apache.commons.collections15.BidiMap; //导入依赖的package包/类
public BidiMap makeFullBidiMap() {
    BidiMap bidi = new DualHashBidiMap();
    for (int i = 0; i < entries.length; i++) {
        bidi.put(entries[i][0], entries[i][1]);
    }
    return UnmodifiableBidiMap.decorate(bidi);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:8,代码来源:TestUnmodifiableBidiMap.java


注:本文中的org.apache.commons.collections15.BidiMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。