本文整理汇总了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));
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}