當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair類代碼示例

本文整理匯總了Java中javafx.util.Pair的典型用法代碼示例。如果您正苦於以下問題:Java Pair類的具體用法?Java Pair怎麽用?Java Pair使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pair類屬於javafx.util包,在下文中一共展示了Pair類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handle

import javafx.util.Pair; //導入依賴的package包/類
@Override
public void handle(ActionEvent event) {
    Optional<Pair<String, String>> opt = new MooConnectDialog().showAndWait();
    if(!opt.isPresent()) return;

    Pair<String, String> pair = opt.get();
    String host = pair.getKey();
    String port = pair.getValue();

    // check values
    if(!Validation.IP.matches(host)) {
        new Alert(Alert.AlertType.ERROR, "The host needs to be a valid IP format!").showAndWait();
        return;
    }
    if(!Validation.INTEGER.matches(port)) {
        new Alert(Alert.AlertType.ERROR, "The port needs to be a valid integer format!").showAndWait();
        return;
    }

    if(Moo.getInstance().isConnected()) return;
    Moo.getInstance().connect("manager", ClientType.INTERFACE, host, Integer.parseInt(port));
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:23,代碼來源:MenuItemConnect.java

示例2: banPlayerAction

import javafx.util.Pair; //導入依賴的package包/類
private void banPlayerAction(ActionEvent e) {
	BanDialog dial = new BanDialog(player.getName(), "No reason indicated", 0);
	dial.setTitle("Ban player");
	dial.setHeaderText("Do you really want to ban " + player.getName() + " ?");
	dial.setContentText("Reason ");
	Optional<Pair<String, Integer>> result = dial.showAndWait();
	
	if (result.isPresent()) {
		Pair<String, Integer> defaultValues = new Pair<String, Integer>("No reason indicated", 0);
		
		try {
			server.banPlayer(player, result.orElse(defaultValues).getValue() + "d", result.orElse(defaultValues).getKey());
		} catch (RCONServerException e1) {
			server.logError(e1);
		}
	}
	
}
 
開發者ID:ScreachFr,項目名稱:titanium,代碼行數:19,代碼來源:PlayerView.java

示例3: headers

import javafx.util.Pair; //導入依賴的package包/類
@Override
public String headers(IXInfoDTO xInfo, Pair... additionalFieldNames) {
	StringBuilder buffer = new StringBuilder();
	if (xInfo != null) {
           Field[] fields = xInfo.getClass().getDeclaredFields();
           // write id
           for (Pair additionalFieldName : additionalFieldNames) {
               buffer.append(additionalFieldName.getKey().toString()).append(SEPERATOR);
           }
           for (Field field : fields) {
                  	// TODO: ist das gut hier ein Accessible zu setzen? Das würde doch eine private methode zu public machen und 
               	// nie wieder zurück tauschen?
                field.setAccessible(true);
                buffer.append(field.getName()); buffer.append(SEPERATOR);
  
           }
           if (xInfo instanceof ISegmentXInfoDTO) {
               buffer.append("direction_tow");
               buffer.append(SEPERATOR);
           }
           buffer.deleteCharAt(buffer.lastIndexOf(SEPERATOR + ""));
       }
	buffer.append(System.getProperty("line.separator"));
	return buffer.toString();
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:26,代碼來源:ReflectionXInfoDTOToCSVConverterImpl.java

示例4: setUpNodeColorSchemeComboBox

import javafx.util.Pair; //導入依賴的package包/類
/**
 * Sets up the {@link ComboBox} listing all node color scheme choices.
 */
private void setUpNodeColorSchemeComboBox() {
    nodeColorScheme.setConverter(new StringConverter<Pair<String, ColorScheme>>() {
        @Override
        public String toString(final Pair<String, ColorScheme> object) {
            return object.getKey();
        }

        @Override
        public Pair<String, ColorScheme> fromString(final String string) {
            return NODE_COLOR_SCHEMES.stream()
                    .filter(pair -> pair.getKey().equals(string))
                    .collect(Collectors.toList()).get(0);
        }
    });
    nodeColorScheme.getItems().addAll(NODE_COLOR_SCHEMES);
    nodeColorScheme.getSelectionModel().selectFirst();
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:21,代碼來源:BasicSettingsViewController.java

示例5: LoadPerformanceResults

import javafx.util.Pair; //導入依賴的package包/類
static void LoadPerformanceResults(String fileName, HashMap<Short, Pair<Short, Long>> perfResultsSubpartsRaw) throws FileNotFoundException, IOException {
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    String strLine;
    while ((strLine = br.readLine()) != null) {
        if (strLine.contains("trapID,")) {
            // skip header line
        }
        else {
            String[] cols = strLine.split(",");
            Short perfID = Short.parseShort(cols[0].trim());
            Short prevPerfID = Short.parseShort(cols[1].trim());
            Long elapsed = Long.parseLong(cols[2].trim());
            
            perfResultsSubpartsRaw.put(perfID, new Pair(prevPerfID, elapsed));
        }
    }
    br.close();
}
 
開發者ID:OpenCryptoProject,項目名稱:JCProfiler,代碼行數:19,代碼來源:PerfTests.java

示例6: buscarServiciosByTipoServicio

import javafx.util.Pair; //導入依賴的package包/類
@Override
public List<Servicio> buscarServiciosByTipoServicio(Servicio.TiposServicio tipoServicio) {
    FachadaIntegracion integra =FachadaIntegracion.newInstance(Servicio.class);

    integra.begin();
    List<Servicio> lista = integra.ejecutarNamedQuery("Servicio.buscarPorTipoServicio", Arrays.asList(new Pair<>("tipoServicio", tipoServicio)));
    integra.commit();

    //El siguiente for es una guarreria de codigo, pero la carga LAZY no funciona bien y la EAGER genera buble infinito
    for(Servicio serv: lista) {
        serv.setProveedor(null);
        serv.setEventoServicios(null);
    }

    return lista;
}
 
開發者ID:EventSoftGroup,項目名稱:EventSoft,代碼行數:17,代碼來源:SAServiciosImp.java

示例7: buscarServiciosEntreFechas

import javafx.util.Pair; //導入依賴的package包/類
@Override
public List<Servicio> buscarServiciosEntreFechas(ArrayList<String> fechas) {
    DateFormat format = new SimpleDateFormat("dd-mm-yyyy");
    ArrayList<Pair> fechasNuevas = new ArrayList<>();

    try {
        Date fechaIni = format.parse(fechas.get(0));
        Date fechaFin = format.parse(fechas.get(1));

        fechasNuevas.add(new Pair("fechaIni", fechaIni));
        fechasNuevas.add(new Pair("fechaFin", fechaFin));
    } catch (ParseException e) {
        e.printStackTrace();
    }

    FachadaIntegracion fachadaIntegracion = FachadaIntegracion.newInstance(Servicio.class);

    fachadaIntegracion.begin();
    List servicios = fachadaIntegracion.ejecutarNamedQuery("Servicio.buscarEntreFechas", Arrays.asList(fechasNuevas));
    fachadaIntegracion.commit();

    return servicios;
}
 
開發者ID:EventSoftGroup,項目名稱:EventSoft,代碼行數:24,代碼來源:SAServiciosImp.java

示例8: Get

import javafx.util.Pair; //導入依賴的package包/類
public Pair<SparseBitSet, SparseBitSet> Get(State forState, int depth, Stack<GraphNode> jumpStack, SparseBitSet shiftedBitMask) {
    Map<String, Pair<SparseBitSet, SparseBitSet>> forStateCache = cache.get(forState);
    if (forStateCache == null)
        return null;
    String key = keyForJumpStack(jumpStack);
    Pair<SparseBitSet, SparseBitSet> cachedUnshiftedMask2UnshiftedRez = forStateCache.get(key);
    if (cachedUnshiftedMask2UnshiftedRez == null)
        return null;
    //check if prevStartingPositions is contained in the prevPoses from cache
    SparseBitSet unshiftedBitMask = shiftedBitMask.clone();
    ShiftOnSentences(unshiftedBitMask, input, depth);

    //B contained by A =  |A and B|  == |B|
    unshiftedBitMask.and(cachedUnshiftedMask2UnshiftedRez.getKey());

    if (unshiftedBitMask.cardinality() == 0)
        return null;//the cached bitmask and the requested bitmask don't intersect at all - return null

    SparseBitSet shiftedBitMaskIntersection = unshiftedBitMask.clone();
    ShiftOnSentences(shiftedBitMaskIntersection, input, -depth);

    SparseBitSet shiftedRezIntersection = cachedUnshiftedMask2UnshiftedRez.getValue().clone();
    ShiftOnSentences(shiftedRezIntersection, input, -depth);
    shiftedRezIntersection.and(shiftedBitMaskIntersection);
    return new Pair<SparseBitSet, SparseBitSet>(shiftedBitMaskIntersection, shiftedRezIntersection);
}
 
開發者ID:radsimu,項目名稱:UaicNlpToolkit,代碼行數:27,代碼來源:SearchSpaceReducer.java

示例9: saveLatexPerfLog

import javafx.util.Pair; //導入依賴的package包/類
static void saveLatexPerfLog(ArrayList<Pair<String, Long>> results) {
    try {
        // Save performance results also as latex
        String logFileName = String.format("MPC_PERF_log_%d.tex", System.currentTimeMillis());
        FileOutputStream perfFile = new FileOutputStream(logFileName);
        String tableHeader = "\\begin{tabular}{|l|c|}\n"
                + "\\hline\n"
                + "\\textbf{Operation} & \\textbf{Time (ms)} \\\\\n"
                + "\\hline\n"
                + "\\hline\n";
        perfFile.write(tableHeader.getBytes());
        for (Pair<String, Long> measurement : results) {
            String operation = measurement.getKey();
            operation = operation.replace("_", "\\_");
            perfFile.write(String.format("%s & %d \\\\ \\hline\n", operation, measurement.getValue()).getBytes());
        }
        String tableFooter = "\\hline\n\\end{tabular}";
        perfFile.write(tableFooter.getBytes());
        perfFile.close();
    } catch (IOException ex) {
        Logger.getLogger(MPCTestClient.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:OpenCryptoProject,項目名稱:Myst,代碼行數:24,代碼來源:MPCTestClient.java

示例10: InsertPerfInfoIntoFiles

import javafx.util.Pair; //導入依賴的package包/類
static void InsertPerfInfoIntoFiles(String basePath, String cardName, String experimentID, HashMap<Short, Pair<Short, Long>> perfResultsSubpartsRaw) throws FileNotFoundException, IOException {
    File dir = new File(basePath);
    String[] filesArray = dir.list();
    if ((filesArray != null) && (dir.isDirectory() == true)) {
        // make subdir for results
        String outputDir = String.format("%s\\perf\\%s\\", basePath, experimentID);
        new File(outputDir).mkdirs();

        for (String fileName : filesArray) {
            File dir2 = new File(basePath + fileName);
            if (!dir2.isDirectory()) {
                InsertPerfInfoIntoFile(String.format("%s\\%s", basePath, fileName), cardName, experimentID, outputDir, perfResultsSubpartsRaw);
            }
        }
    }
}
 
開發者ID:OpenCryptoProject,項目名稱:Myst,代碼行數:17,代碼來源:MPCTestClient.java

示例11: internalProcess

import javafx.util.Pair; //導入依賴的package包/類
@Override
public void internalProcess() {
    try {
        while (isRunning && !Thread.currentThread().isInterrupted()) {
            Pair<byte[], Long> toRead;
            toRead = byteQueue.poll(5, TimeUnit.SECONDS);
            if (toRead == null) {
                continue;
            }
            byte[] bytesToRead = toRead.getKey();
            if (bytesToRead.length == 0) {
                isRunning = false;
                return;
            }
            matchThings(bytesToRead, toRead.getValue());
        }
    }
    catch (InterruptedException e) {
        Logging.log(e);
        return;
    }
}
 
開發者ID:ciphertechsolutions,項目名稱:IO,代碼行數:23,代碼來源:MagicCarver.java

示例12: StreamDataset

import javafx.util.Pair; //導入依賴的package包/類
public StreamDataset(String name, StreamingDataSource dataSource, int
        memoryCapacity) {
    this.uniqueName = name;
    this.stream = dataSource;
    indexes = new ArrayList<>();
    indexesActivators = new ArrayList<>();
    preprocessor = stream.getPreprocessor();

    if(memoryCapacity > 0)
        streamData = new ArrayBigDataset(memoryCapacity);
    else
        streamData = new ArrayBigDataset();

    List<List<Microblog>> tempLst = new ArrayList<>();
    tempRecoveryDataList = Collections.synchronizedList(tempLst);

    //if existing stream, load recoveryBlkCounter and latest id
    Pair<String,String> dirFileidPair = getRecoveryFileIdPrefix();
    Pair<Integer, Long> existingIds = KiteUtils.loadStreamIds
            (dirFileidPair, stream.getScheme());
    recoveryBlkCounter = existingIds.getKey();
    currId = new IdGenerator(existingIds.getValue()+1);
}
 
開發者ID:amrmagdy4,項目名稱:kite,代碼行數:24,代碼來源:StreamDataset.java

示例13: getTime

import javafx.util.Pair; //導入依賴的package包/類
/**
 * Gets the duration and timeunit from string (like 1d or 5h)
 *
 * @param str The string
 * @return The pair with both values
 */
public static Pair<Integer, TimeUnit> getTime(String str) {
    if(!Validation.TIME.matches(str)) return null;
    String timeUnitStr = str.substring(str.length() - 1, str.length());
    int duration = Integer.parseInt(str.substring(0, str.length() - 1));

    TimeUnit unit = null;
    switch(timeUnitStr) {
        case "d":
            unit = TimeUnit.DAYS;
            break;
        case "h":
            unit = TimeUnit.HOURS;
            break;
        case "m":
            unit = TimeUnit.MINUTES;
            break;
        case "s":
            unit = TimeUnit.SECONDS;
            break;
    }
    return new Pair<>(duration, unit);
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:29,代碼來源:TimeUtil.java

示例14: testFilterSmallInputInMidBigMargin_GLUCOSE_BG

import javafx.util.Pair; //導入依賴的package包/類
@Test
//Filtered results are spread over the dataset, not located directly at the beginning nor the end of the dataset
//Only small pre-result list, e.g. 2 entrys
public void testFilterSmallInputInMidBigMargin_GLUCOSE_BG() throws ParseException {
    FilterResult result;
    FilterResult expectedResult;
    List<Pair<Date, Date>> expectedTimeSeries = new ArrayList<>();
    List<VaultEntry> vaultEntries = new ArrayList<>(dataSet);
    List<VaultEntryAnnotation> tmpAnnotations;

    setUpFilterUnderTest(new EventFilter(VaultEntryType.GLUCOSE_BG), 4 * 60);
    result = filterUnderTest.filter(dataSet);

    vaultEntries.remove(vaultEntries.size() - 1);
    vaultEntries.remove(vaultEntries.size() - 1);
    expectedTimeSeries.add(new Pair(TimestampUtils.createCleanTimestamp("2017.06.29-04:46", "yyyy.MM.dd-HH:mm"),
            TimestampUtils.createCleanTimestamp("2017.06.29-12:31", "yyyy.MM.dd-HH:mm")));
    expectedResult = new FilterResult(vaultEntries, expectedTimeSeries);

    assertEquals(expectedResult.filteredData, result.filteredData);
    assertEquals(expectedResult.timeSeries, result.timeSeries);

}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:24,代碼來源:ContinuousWrapperTest.java

示例15: testDateTimePointFilter_margin_10

import javafx.util.Pair; //導入依賴的package包/類
@Test
public void testDateTimePointFilter_margin_10() throws ParseException {
    Date dateTimePoint = TestFunctions.creatNewDateToCheckFor("2017.06.29-12:15");
    int marginInMinutes = 10;
    // 2017.06.29-12:05 - 2017.06.29-12:25
    instance = new DateTimePointFilter(dateTimePoint,marginInMinutes);
    FilterResult result = instance.filter(data);

    List<VaultEntry> filteredData = new ArrayList<>();
    filteredData.add(new VaultEntry(VaultEntryType.STRESS, TestFunctions.creatNewDateToCheckFor("2017.06.29-12:11"), 17.25));
    filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE_VARIABILITY, TestFunctions.creatNewDateToCheckFor("2017.06.29-12:11"), 41.0, 131.0));
    filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE, TestFunctions.creatNewDateToCheckFor("2017.06.29-12:21"), 51.0));
    filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE_VARIABILITY, TestFunctions.creatNewDateToCheckFor("2017.06.29-12:21"), 44.0, 127.0));
    filteredData.add(new VaultEntry(VaultEntryType.STRESS, TestFunctions.creatNewDateToCheckFor("2017.06.29-12:21"), 18.25));
    
    
    List<Pair<Date, Date>> timeSeries = new ArrayList<>();
    timeSeries.add(new Pair<>(TestFunctions.creatNewDateToCheckFor("2017.06.29-12:11"), TestFunctions.creatNewDateToCheckFor("2017.06.29-12:21")));
    
    FilterResult checkForThisResult = new FilterResult(filteredData, timeSeries);
    
    assertEquals(result.filteredData, checkForThisResult.filteredData);
    assertEquals(result.timeSeries, checkForThisResult.timeSeries);
    //assertEquals(result, checkForThisResult);
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:26,代碼來源:DateTimePointFilterTest.java


注:本文中的javafx.util.Pair類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。