Example usage for org.apache.commons.collections4.bidimap DualHashBidiMap DualHashBidiMap

List of usage examples for org.apache.commons.collections4.bidimap DualHashBidiMap DualHashBidiMap

Introduction

In this page you can find the example usage for org.apache.commons.collections4.bidimap DualHashBidiMap DualHashBidiMap.

Prototype

public DualHashBidiMap() 

Source Link

Document

Creates an empty HashBidiMap.

Usage

From source file:com.offbynull.peernetic.debug.visualizer.JGraphXVisualizer.java

/**
 * Creates a {@link JGraphXVisualizer} object.
 *//* w  w w . j a  v a2  s  . c o m*/
public JGraphXVisualizer() {

    graph = new mxGraph();
    graph.setCellsEditable(false);
    graph.setAllowDanglingEdges(false);
    graph.setAllowLoops(false);
    graph.setCellsDeletable(false);
    graph.setCellsCloneable(false);
    graph.setCellsDisconnectable(false);
    graph.setDropEnabled(false);
    graph.setSplitEnabled(false);
    graph.setCellsBendable(false);
    graph.setConnectableEdges(false);
    graph.setCellsMovable(false);
    graph.setCellsResizable(false);
    graph.setAutoSizeCells(true);

    component = new mxGraphComponent(graph);
    component.setConnectable(false);

    component.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    component.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    nodeLookupMap = new DualHashBidiMap<>();
    connToEdgeLookupMap = new MultiValueMap<>();
    edgeToConnLookupMap = new HashMap<>();
    vertexLingerTriggerMap = new HashMap<>();

    textOutputArea = new JTextArea();
    textOutputArea.setLineWrap(false);
    textOutputArea.setEditable(false);
    JScrollPane textOutputScrollPane = new JScrollPane(textOutputArea);
    textOutputScrollPane.setPreferredSize(new Dimension(0, 100));

    frame = new JFrame("Visualizer");
    frame.setSize(400, 400);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, textOutputScrollPane);
    splitPane.setResizeWeight(1.0);

    frame.setContentPane(splitPane);

    component.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            zoomFit();
        }
    });

    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            Recorder<A> rec = recorder.get();
            if (rec != null) {
                IOUtils.closeQuietly(rec);
            }

            VisualizerEventListener veListener = listener.get();
            if (veListener != null) {
                veListener.closed();
            }
        }
    });

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    splitPane.setDividerLocation(0.2);
}

From source file:net.sf.jasperreports.engine.data.JRCsvDataSource.java

protected void assignColumnNames() {
    BidiMap<Integer, String> indexColumns = new DualHashBidiMap<Integer, String>();
    for (int i = 0; i < crtRecordColumnValues.size(); i++) {
        String name = crtRecordColumnValues.get(i);

        Integer existingIdx = indexColumns.getKey(name);
        if (existingIdx == null) {
            //use the name from the file if possible
            indexColumns.put(i, name);/*from  w  w  w . j  av a 2  s  .  co m*/
        } else {
            //the name is taken, force COLUMN_i for this column and recursively if COLUMN_x is already used
            Integer forceIndex = i;
            do {
                String indexName = INDEXED_COLUMN_PREFIX + forceIndex;
                Integer existingIndex = indexColumns.getKey(indexName);
                indexColumns.put(forceIndex, indexName);
                forceIndex = existingIndex;
            } while (forceIndex != null);
        }
    }

    this.columnNames = new LinkedHashMap<String, Integer>();
    for (int i = 0; i < crtRecordColumnValues.size(); i++) {
        String columnName = indexColumns.get(i);
        this.columnNames.put(columnName, i);
    }
}

From source file:org.codice.ddf.spatial.ogc.wfs.catalog.mapper.impl.MetacardMapperImpl.java

public MetacardMapperImpl() {
    LOGGER.debug("Creating {}", MetacardMapperImpl.class.getName());
    bidiMap = new DualHashBidiMap<String, String>();
}

From source file:org.dawnsci.plotting.tools.preference.FittingPreferencePage.java

@Override
protected Control createContents(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(1, false));
    GridData gdc = new GridData(SWT.FILL, SWT.FILL, true, true);
    comp.setLayoutData(gdc);//  w  ww . j  av  a 2  s . c  o m

    Group algGroup = new Group(comp, SWT.NONE);
    algGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    algGroup.setLayout(new GridLayout(2, false));
    algGroup.setText("Peak Fitting Algorithm Controls");

    Label accuractlab = new Label(algGroup, SWT.NONE);
    accuractlab.setText("Accuracy");
    accuractlab.setToolTipText("This sets the accuracy of the optimisation. "
            + "The lower the number to more accurate the calculation");

    accuracy = new FloatSpinner(algGroup, SWT.BORDER, 6, 5);
    accuracy.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
    accuracy.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            storePreferences();
        }
    });

    Label smoothingLab = new Label(algGroup, SWT.NONE);
    smoothingLab.setText("Smoothing");
    smoothingLab.setToolTipText(
            "Smoothing over that many data points will be applied by the peak searching algorithm");

    smoothing = new Spinner(algGroup, SWT.BORDER);
    smoothing.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
    smoothing.setDigits(0);
    smoothing.setMinimum(0);
    smoothing.setMaximum(10000);
    smoothing.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            storePreferences();
        }
    });

    Label peaksLab = new Label(algGroup, SWT.NONE);
    peaksLab.setText("Number of peaks");
    peaksLab.setToolTipText("The peak number to fit");

    peakNumber = new Spinner(algGroup, SWT.BORDER);
    peakNumber.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
    peakNumber.setDigits(0);
    peakNumber.setMinimum(1);
    peakNumber.setMaximum(1000);
    peakNumber.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            storePreferences();
        }
    });

    Group formatGrp = new Group(comp, SWT.NONE);
    formatGrp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    formatGrp.setLayout(new GridLayout(2, false));
    formatGrp.setText("Peak Format");

    Label realFormatLab = new Label(formatGrp, SWT.NONE);
    realFormatLab.setText("Real Format");
    realFormatLab.setToolTipText("Format for real numbers shown in the peak fitting table.");

    realFormat = new Text(formatGrp, SWT.BORDER);
    realFormat.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
    realFormat.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            storePreferences();
        }
    });

    Group accuracyGroup = new Group(comp, SWT.NONE);
    accuracyGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    accuracyGroup.setLayout(new GridLayout(2, false));
    accuracyGroup.setText("Function Fitting Algorithm Controls");

    Label accuracyInfoLabel = new Label(accuracyGroup, SWT.NONE);
    accuracyInfoLabel.setText("Accuracy of Fitting Routine");
    accuracyValueText = new Text(accuracyGroup, SWT.BORDER);
    accuracyValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label algoLabel = new Label(accuracyGroup, SWT.NONE);
    algoLabel.setText("Fitting Algorithm");
    algorithmCombo = new CCombo(accuracyGroup, SWT.BORDER);
    algorithmCombo.setEditable(false);
    algorithmCombo.setListVisible(true);
    algorithmCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    algorithmComboMap = new DualHashBidiMap<Integer, FIT_ALGORITHMS>();
    for (int i = 0; i < FIT_ALGORITHMS.values().length; i++) {
        FIT_ALGORITHMS algorithm = FIT_ALGORITHMS.values()[i];
        algorithmCombo.add(algorithm.NAME);
        algorithmComboMap.put(i, algorithm);
    }

    // initialize
    initializePage();
    return comp;
}

From source file:org.efaps.esjp.accounting.util.PeriodCarryOver_Base.java

/**
 * Creates the from period./*from   w  w w .j  a  v  a 2 s.  com*/
 *
 * @param _parameter the parameter
 * @param _basePeriodInst the base period inst
 * @throws EFapsException the eFaps exception
 */
public void createFromPeriod(final Parameter _parameter, final Instance _basePeriodInst) throws EFapsException {
    LOG.info("Init carry over for Period");
    final Instance periodInst = createPeriod(_parameter, _basePeriodInst);

    final BidiMap<Instance, Instance> existing2new = new DualHashBidiMap<>();

    createAccounts(_parameter, _basePeriodInst, periodInst, existing2new);
    createReports(_parameter, _basePeriodInst, periodInst, existing2new);
    createCases(_parameter, _basePeriodInst, periodInst, existing2new);
    createPeriod2Account(_parameter, _basePeriodInst, periodInst, existing2new);
    createAccount2Account(_parameter, _basePeriodInst, periodInst, existing2new);

}

From source file:org.jspresso.framework.qooxdoo.rpc.RemoteCallUtils.java

/**
 * Handles Lists./*  w ww  . ja  v a  2s  .  co  m*/
 * <p/>
 * {@inheritDoc}
 */
@Override
public Object fromJava(Object obj)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, JSONException {
    BidiMap<String, String> codec = CODEC.get();
    boolean initialCall = false;
    if (codec == null) {
        initialCall = true;
        codec = new DualHashBidiMap<>();
        CODEC.set(codec);
    }
    try {
        Object returnValue;
        if (obj instanceof List<?>) {
            List<?> list = (List<?>) obj;
            JSONObject jsonObject = new JSONObject();
            jsonObject.put(encode("class"), encode("qx.data.Array"));
            jsonObject.put(encode("array"), fromJava(list.toArray()));
            returnValue = jsonObject;
        } else if (obj instanceof BigDecimal) {
            returnValue = super.fromJava(((BigDecimal) obj).doubleValue());
        } else if (obj instanceof BigInteger) {
            returnValue = super.fromJava(((BigInteger) obj).longValue());
        } else {
            returnValue = super.fromJava(obj);
        }
        if (initialCall) {
            JSONObject wrapper = new JSONObject();
            wrapper.put("codec", new JSONObject(codec));
            wrapper.put("payload", returnValue);
            returnValue = wrapper;
        }
        return returnValue;
    } finally {
        if (initialCall) {
            CODEC.remove();
        }
    }
}

From source file:org.linqs.psl.experimental.reasoner.general.JSONSerialTermStore.java

public JSONSerialTermStore() {
    super();

    variableIds = new DualHashBidiMap<RandomVariableAtom, Integer>();
}

From source file:org.lockss.util.OneToOneNamespaceContext.java

/**
 * <p>//from   w ww.  ja va 2s .  c  o  m
 * Builds a new instance that initially maps
 * {@link XMLConstants#DEFAULT_NS_PREFIX} to {@link XMLConstants#NULL_NS_URI}.
 * </p>
 * 
 * @since 1.67.5
 */
public OneToOneNamespaceContext() {
    this.bidiMap = new DualHashBidiMap<String, String>();
    put(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI);
}

From source file:org.orbisgis.corejdbc.internal.ReadRowSetImpl.java

protected void cacheColumnNames() throws SQLException {
    cachedColumnNames = new DualHashBidiMap<>();
    try (Resource res = resultSetHolder.getResource()) {
        ResultSetMetaData meta = res.getResultSet().getMetaData();
        for (int idColumn = 1; idColumn <= meta.getColumnCount(); idColumn++) {
            cachedColumnNames.put(meta.getColumnName(idColumn), idColumn);
        }//from w w w . j  a  v  a2 s  . c  om
    }
}

From source file:pltag.parser.ShadowStringTree.java

public Map<Short, Short> getOffsetNodeIds() {
    DualHashBidiMap<Short, Short> map = new DualHashBidiMap<Short, Short>();
    for (Integer id : tree.getNodes()) {
        map.put(id.shortValue(),// w ww  . ja v  a2  s.co  m
                id == elemIpiNode ? prefixIpiNode : (short) (id + absolutePosOfRootInPrefixTree));
    }
    return map;
}