public void initData(int regionCode) { // 一定能选中省 provinceAdapter.addHeader( (provinceHeader = new RegionHeaderView(callback, new Region(0, 1, 100000, 100000, "不限"), "不限"))); ArrayList<Region> arrProvince = RegionModel.getInstance().getProvinceList(); provinceAdapter.addAll(arrProvince); Region provinceRegion = RegionModel.getInstance().findProvince(regionCode); if (provinceRegion == null) { provinceRegion = arrProvince.get(0); } province.scrollToPosition(arrProvince.indexOf(provinceRegion) + 1); // 一定要选中市 cityAdapter.addHeader((cityHeader = new RegionHeaderView(callback, provinceRegion, "全部"))); ArrayList<Region> arrCity = RegionModel.getInstance().getCityList(provinceRegion.getCid()); cityAdapter.addAll(arrCity); Region cityRegion = RegionModel.getInstance().findCity(regionCode); if (cityRegion == null) { cityRegion = arrCity.get(0); } city.scrollToPosition(arrCity.indexOf(cityRegion) + 1); // 一定要选中区 regionAdapter.addHeader((regionHeader = new RegionHeaderView(callback, cityRegion, "全部"))); ArrayList<Region> arrRegion = RegionModel.getInstance().getRegionList(cityRegion.getCid()); regionAdapter.addAll(arrRegion); Region regionRegion = RegionModel.getInstance().findRegion(regionCode); if (regionRegion == null) { regionRegion = arrRegion.get(0); } region.scrollToPosition(arrRegion.indexOf(regionRegion) + 1); }
private void selectNavPosition(int type, int catID, String title) { // switch (type) { // case TasksTable.TASK_TYPE_COMMING_UP: // mDrawerList.setItemChecked(mCatList.indexOf(type), true); // mDrawerList.setSelection(mCatList.indexOf(type)); // break; // case TasksTable.TASK_TYPE_NEXT_SEVEN_DAYS: // mDrawerList.setItemChecked(mCatList.indexOf(type), true); // mDrawerList.setSelection(mCatList.indexOf(type)); // break; // case TasksTable.TASK_TYPE_ALL_TASKS: // mDrawerList.setItemChecked(mCatList.indexOf(type), true); // mDrawerList.setSelection(mCatList.indexOf(type)); // break; // case TasksTable.TASK_TYPE_SHOPPING: // mDrawerList.setItemChecked(mCatList.indexOf(type), true); // mDrawerList.setSelection(mCatList.indexOf(type)); // break; // // default: // mDrawerList.setItemChecked(mCatList.indexOf(catID), true); // mDrawerList.setSelection(mCatList.indexOf(catID)); // break; // } mDrawerList.setItemChecked(mCatList.indexOf(catID), true); mDrawerList.setSelection(mCatList.indexOf(catID)); setTitle(title); mDrawerLayout.closeDrawer(Gravity.START); }
void doStructure(final CyNetwork net) { srcs = new ArrayList<Integer>(edges.size()); tgts = new ArrayList<Integer>(edges.size()); adjacency = new ArrayList<ArrayList<Integer>>(nodes.size()); Collections.sort( nodes, new Comparator<CyNode>() { public int compare(CyNode n1, CyNode n2) { return net.getRow(n1) .get(CyNetwork.NAME, String.class) .compareTo(net.getRow(n2).get(CyNetwork.NAME, String.class)); } }); Collections.sort( edges, new Comparator<CyEdge>() { public int compare(CyEdge n1, CyEdge n2) { return net.getRow(n1) .get(CyNetwork.NAME, String.class) .compareTo(net.getRow(n2).get(CyNetwork.NAME, String.class)); } }); for (int i = 0; i < nodes.size(); i++) adjacency.add(new ArrayList<Integer>()); for (int e = 0; e < edges.size(); e++) { int src = nodes.indexOf(edges.get(e).getSource()); srcs.add(src); adjacency.get(src).add(e); tgts.add(nodes.indexOf(edges.get(e).getTarget())); } }
public static void main(String[] args) { ArrayList<Object> list = new ArrayList<>(); list.add("홍길동"); list.add("임꺽정"); list.add(new Integer(10)); list.add(new Date()); System.out.println(list.indexOf("임꺽정")); // 1 // indexOf()는 레퍼런스 주소가 아니라 내용을 비교한다. System.out.println(list.indexOf(new String("임꺽정"))); // 1 System.out.println("홍길동" == new String("홍길동")); // 서로 다른 레퍼런스. System.out.println(list.contains(new String("홍길동"))); // 내용이 같은지 비교 System.out.println("--------------------------"); ArrayList<Object> list2 = new ArrayList<>(); list2.add("오호라"); list2.add("우헤헤"); list.addAll(list2); // for (레퍼런스 : 배열 또는 Collection 타입 객체) {} // => 배열 또는 컬렉션 전체를 반복한다. for (Object element : list) { System.out.println(element); } }
/** @tests java.util.ArrayList#ensureCapacity(int) */ public void test_ensureCapacityI() { // Test for method void java.util.ArrayList.ensureCapacity(int) // TODO : There is no good way to test this as it only really impacts on // the private implementation. Object testObject = new Object(); int capacity = 20; ArrayList al = new ArrayList(capacity); int i; for (i = 0; i < capacity / 2; i++) { al.add(i, new Object()); } al.add(i, testObject); int location = al.indexOf(testObject); al.ensureCapacity(capacity); assertTrue( "EnsureCapacity moved objects around in array1.", location == al.indexOf(testObject)); al.remove(0); al.ensureCapacity(capacity); assertTrue( "EnsureCapacity moved objects around in array2.", --location == al.indexOf(testObject)); al.ensureCapacity(capacity + 2); assertTrue("EnsureCapacity did not change location.", location == al.indexOf(testObject)); ArrayList<String> list = new ArrayList<String>(1); list.add("hello"); list.ensureCapacity(Integer.MIN_VALUE); }
/** * Draws the arrows between the nodes * * @param attributes the attributes of the relation * @param fd the functionalDependency to display * @param nearNodes the Array of Nodes which are closer to the attribute-Nodes * @param farNodes the Array of Nodes which are further away of the attribute-Nodes */ private void drawAttributeArrows( ArrayList<Attribute> attributes, FunctionalDependency fd, ArrayList<mxCell> nearNodes, ArrayList<mxCell> farNodes) { int index; ArrayList<Integer> indices = new ArrayList<>(); // draw arrows for the SourceAttributes for (Attribute sourceAttr : fd.getSourceAttributes()) { index = attributes.indexOf(sourceAttr); graph.insertEdge( parentPane, null, fd, nearNodes.get(index), farNodes.get(index), "EDGE_PLAIN"); indices.add(index); } // draw arrows for the TargetAttributes for (Attribute targetAttr : fd.getTargetAttributes()) { index = attributes.indexOf(targetAttr); graph.insertEdge( parentPane, null, fd, farNodes.get(index), nearNodes.get(index), "EDGE_ARROW"); indices.add(index); } // Connect arrows java.util.Collections.sort(indices); graph.insertEdge( parentPane, null, fd, farNodes.get(indices.get(0)), farNodes.get(indices.get(indices.size() - 1)), "EDGE_PLAIN"); }
/* * This method lines up two AI's links, aka genes, and returns the order of the lined up genes, and where they occur. * This method returns an arraylist of arraylist of Integer. * The outer arraylist contains arraylists on: * 0: neuron historical ID of links present in the two AI * 1: where in the first ai's link list the link occurs * 2: where in the second ai's link list the link occurs */ public ArrayList<ArrayList<Integer>> lineUpAILinks(NeatAI second) { ArrayList<Gene> secondL = second.getCloneLinks(); ArrayList<Integer> ai1histIDlist = new ArrayList<Integer>(); ArrayList<Integer> ai2histIDlist = new ArrayList<Integer>(); ArrayList<Integer> linkID = new ArrayList<Integer>(); ArrayList<Integer> linkList1Pos = new ArrayList<Integer>(); ArrayList<Integer> linkList2Pos = new ArrayList<Integer>(); // Get genes. int histID; for (Gene l : links) { histID = l.getHistID(); linkID.add(histID); ai1histIDlist.add(histID); } int pos; for (Gene l : secondL) { histID = l.getHistID(); pos = linkID.indexOf(histID); if (pos == -1) { // New histID found linkID.add(histID); } ai2histIDlist.add(histID); } // Sort genes // Bubble sort, meh int lowest; for (int i = 0; i < linkID.size(); i++) { lowest = i; for (int j = i + 1; j < linkID.size(); j++) { if (linkID.get(j) < linkID.get(lowest)) { lowest = j; } } int temp = linkID.get(i); linkID.set(i, linkID.get(lowest)); linkID.set(lowest, temp); } // Add gene positions for (Integer tempID : linkID) { linkList1Pos.add(ai1histIDlist.indexOf(tempID)); linkList2Pos.add(ai2histIDlist.indexOf(tempID)); } ArrayList<ArrayList<Integer>> temp = new ArrayList<ArrayList<Integer>>(); temp.add(linkID); temp.add(linkList1Pos); temp.add(linkList2Pos); return temp; }
public String toDOTString() { StringBuilder sb = new StringBuilder(); sb.append("digraph onzeMooieGraph {\nrankdir=LR;\n"); for (Vertex vertex : vertices) { sb.append( String.format( "n%d [label=\"%s (" + vertex.getEarliestTime() + "," + vertex.getLatestTime() + ")\" shape=\"square\"];\n", vertices.indexOf(vertex), vertex.getValue())); } for (Edge edge : edges) { sb.append( String.format( "n%d -> n%d [ label = \"%d\" ];\n", vertices.indexOf(edge.getFrom()), vertices.indexOf(edge.getTo()), edge.getWeight())); } sb.append("}"); return sb.toString(); }
/** If force is true, this method skips the check for newTab == current. */ private boolean setCurrentTab(Tab newTab, boolean force) { Tab current = getTab(mCurrentTab); if (current == newTab && !force) { return true; } if (current != null) { current.putInBackground(); mCurrentTab = -1; } if (newTab == null) { return false; } // Move the newTab to the end of the queue int index = mTabQueue.indexOf(newTab); if (index != -1) { mTabQueue.remove(index); } mTabQueue.add(newTab); // Display the new current tab mCurrentTab = mTabs.indexOf(newTab); WebView mainView = newTab.getWebView(); boolean needRestore = mainView == null; if (needRestore) { // Same work as in createNewTab() except don't do new Tab() mainView = createNewWebView(); newTab.setWebView(mainView); } newTab.putInForeground(); return true; }
private static void getTopDocuments(int num, HashMap<String, Float> scoremap, String filename) throws FileNotFoundException { PrintWriter out = new PrintWriter(filename); Iterator<String> itr = scoremap.keySet().iterator(); ArrayList<String> urls = new ArrayList<String>(); ArrayList<Float> scores = new ArrayList<Float>(); while (itr.hasNext()) { String key = itr.next(); if (scores.size() < num) { scores.add(scoremap.get(key)); urls.add(key); } else { int index = scores.indexOf(Collections.min(scores)); if (scores.get(index) < scoremap.get(key)) { scores.set(index, scoremap.get(key)); urls.set(index, key); } } } while (scores.size() > 0) { int index = scores.indexOf(Collections.max(scores)); out.println(urls.get(index) + "\t" + scores.get(index)); urls.remove(index); scores.remove(index); } out.close(); }
void handleScanFiles(JTextField field, String[] extensions) { String[] dataFiles = scanDataFolderForFilesByType(extensions); if (dataFiles == null || dataFiles.length == 0) return; String[] oldFileList = field.getText().trim().split(","); ArrayList<String> newFileList = new ArrayList<String>(); for (String c : oldFileList) { c = c.trim(); if (!c.equals("") && newFileList.indexOf(c) == -1) // TODO check exists() here? { newFileList.add(c); } } for (String c : dataFiles) { c = c.trim(); if (!c.equals("") && newFileList.indexOf(c) == -1) { newFileList.add(c); } } Collections.sort(newFileList); String finalFileList = ""; int i = 0; for (String s : newFileList) { finalFileList += (i > 0 ? ", " : "") + s; i++; } field.setText(finalFileList); }
/** * Moves a pile the user selects over 2 piles * * @param cardSelected The card to be moved * @param isAI Whether the AI called the function or not * @param isLegal Whether the move is legal or not */ private void movePileTwoPlacesLeft(int cardSelected, boolean isAI, boolean isLegal) { int selectedCard = cardSelected - 1; int movePlace = selectedCard - 3; if (cardStrings.size() > 3 && selectedCard > 2 && selectedCard < cardStrings.size()) { if (!isAI) { // If the AI is calling this function, isLegal has already been decided, so // shouldn't be changed isLegal = false; } if (!isAI) { isLegal = piles.movePileTwoPlacesLeft(isLegal, selectedCard, moveMade); } if (isLegal) { // If the move can be made String cardToMove = cardStrings.get(selectedCard); // Get the pile you want to move int moveTarget = movePlace; while (cardStrings.indexOf(cardToMove) != moveTarget) { // while the pile isn't in the correct new position int i = cardStrings.indexOf(cardToMove); Collections.swap(cardStrings, i, i - 1); // Swap the pile with the one next to it } int index = cardStrings.indexOf(cardToMove) + 1; // Get the index of the pile being removed String cardToDelete = cardStrings.get(index); // Get the pile in that index cardStrings.remove(cardToDelete); // Remove the pile the pile was placed onto saveLog(); } printFrame(); } else { if (!isAI) { System.out.println("There is no pile to move the selected pile onto"); } } }
public String CorrectAnsOrderFinder(String[] correctAns, ArrayList options) { for (int i = 0; i < correctAns.length; i++) { if (correctAns[i].contains("language")) { // tempValue = tempValue.replace("language", ""); String[] splitTempValue = correctAns[i].split("\\s+"); correctAns[i] = splitTempValue[0]; } } Map<Integer, String> indexToAns = new HashMap<Integer, String>(); List<Integer> index = new <Integer>ArrayList(); String correctOrder = null; System.out.println(options); try { for (String ans : correctAns) { System.out.println("Ans=" + ans); if (options.indexOf(ans) < 0) continue; index.add(options.indexOf(ans)); indexToAns.put(options.indexOf(ans), ans); } } catch (Exception e) { e.printStackTrace(); System.out.println(options); } Collections.sort(index); for (int i = 0; i < index.size(); i++) { if (correctOrder != null) correctOrder = correctOrder + "," + indexToAns.get(index.get(i)); else correctOrder = indexToAns.get(index.get(i)); } return correctOrder; }
public static openControlledVocabulary inferLocation(interaction interaction) { // I do not want to intialize a map for such a simple operation so // I will use two array lists instead ArrayList<openControlledVocabulary> ocvs = new ArrayList<openControlledVocabulary>(5); ArrayList<Integer> counts = new ArrayList<Integer>(5); Set<InteractionParticipant> ips = interaction.getPARTICIPANTS(); for (InteractionParticipant ip : ips) { if (ip instanceof physicalEntityParticipant) { openControlledVocabulary ocv = ((physicalEntityParticipant) ip).getCELLULAR_LOCATION(); int i = ocvs.indexOf(ocv); if (i == -1) { counts.add(1); ocvs.add(ocv); } else { counts.add(i, counts.get(i) + 1); } } } int max = -1; for (int count : counts) { if (count > max) { max = count; } } int maxIndex = counts.indexOf(max); if (maxIndex == -1) { return null; } else { return ocvs.get(maxIndex); } }
public void collapse() { ArrayList<BinaryGraph> subgraphs = null; for (int index = 0; index < _goalParts.size(); index++) { BinaryGraph goalPart = _goalParts.get(index); if (subgraphs == null) { subgraphs = goalPart.getSubgraphs(new ArrayList<BinaryGraph>()); continue; } else { ArrayList<BinaryGraph> tempSubtrees = goalPart.getSubgraphs(subgraphs); for (int tempIndex = 0; tempIndex < tempSubtrees.size(); tempIndex++) { BinaryGraph tempGraph = tempSubtrees.get(tempIndex); if (subgraphs.contains(tempGraph)) { // Determine if tempGraph is lefty or righty BinaryGraph parent = tempGraph.getParent(0); if (parent == null) { // TODO: decide what to do if parent does not exist } else if (parent.getLeft().equals(tempGraph)) { parent.setLeft(subgraphs.get(subgraphs.indexOf(tempGraph))); } else { parent.setRight(subgraphs.get(subgraphs.indexOf(tempGraph))); } } else { subgraphs.add(tempGraph); subgraphs = sortList(subgraphs); } } } } calculateStagesSteps(); }
private static boolean greedySwitch( ArrayList<TestResult> testSuite, ArrayList<TestResult> unused) { TestResult max = unused.get(0); TestResult min = testSuite.get(0); for (TestResult i : testSuite) { if (i.getUniqueMutants().size() < min.getUniqueMutants().size()) { min = i; } } for (TestResult i : unused) { if (i.getUniqueMutants().size() > max.getUniqueMutants().size()) { max = i; } } if (min.getUniqueMutants().equals(0) && !(max.getUniqueMutants().equals(0))) { int testSuiteLoc = testSuite.indexOf(min); testSuite.remove(testSuiteLoc); testSuite.add(testSuiteLoc, max); int unusedLoc = unused.indexOf(max); unused.remove(unusedLoc); unused.add(unusedLoc, min); return true; } return false; }
/** * Loads values for symbols in the expression * * @param sc Scanner for values input * @throws IOException If there is a problem with the input */ public void loadSymbolValues(Scanner sc) throws IOException { while (sc.hasNextLine()) { StringTokenizer st = new StringTokenizer(sc.nextLine().trim()); int numTokens = st.countTokens(); String sym = st.nextToken(); ScalarSymbol ssymbol = new ScalarSymbol(sym); ArraySymbol asymbol = new ArraySymbol(sym); int ssi = scalars.indexOf(ssymbol); int asi = arrays.indexOf(asymbol); if (ssi == -1 && asi == -1) { continue; } int num = Integer.parseInt(st.nextToken()); if (numTokens == 2) { // scalar symbol scalars.get(ssi).value = num; } else { // array symbol asymbol = arrays.get(asi); asymbol.values = new int[num]; // following are (index,val) pairs while (st.hasMoreTokens()) { String tok = st.nextToken(); StringTokenizer stt = new StringTokenizer(tok, " (,)"); int index = Integer.parseInt(stt.nextToken()); int val = Integer.parseInt(stt.nextToken()); asymbol.values[index] = val; } } } }
private void moveHelper(LIST list, Filter filter, Node moveThis, Node beforeThis) { Node oldParent = moveThis.parent; ArrayList<Node> oldSiblings = oldParent.children; Node newParent = beforeThis.parent; ArrayList<Node> newSiblings = newParent.children; int beforeIndex = newSiblings.indexOf(beforeThis); if (beforeIndex < 0) { return; } int nodeIndex = oldSiblings.indexOf(moveThis); if (nodeIndex < 0) { return; } moveThis.parent = newParent; setNodeIndent(moveThis, newParent.indent + 1); oldSiblings.remove(moveThis); if (newSiblings == oldSiblings && beforeIndex > nodeIndex) { beforeIndex--; } newSiblings.add(beforeIndex, moveThis); writeSerialization(list, serializeTree(), true); applyToFilter(filter); }
/** * estimatedParameters[estimators][sizeOfSample][par][k] = value * * @param estimator...type of estimator * @param sizeOfSample... size of sample which was estimated * @param par... one of {1,2,3}. Is estimated parameter of the pdf * @param k...number of estimation in the series of K estimations * @param value... value of the estimated parameter */ public void setEstimatedParameter( EstimatorBuilder estimator, int n, int par, int k, double value) { int estI = estimators.indexOf(estimator); int nI = sizeOfSample.indexOf(n); estimatedParameter[estimators.indexOf(estimator)][sizeOfSample.indexOf(n)][par - 1][k] = value; }
private void next() { int index = mMediaList.indexOf(mCurrentMedia); mPrevious.push(mCurrentMedia); if (mRepeating == RepeatType.Once) mCurrentMedia = mMediaList.get(index); else if (mShuffling && mPrevious.size() < mMediaList.size()) { while (mPrevious.contains( mCurrentMedia = mMediaList.get((int) (Math.random() * mMediaList.size())))) ; } else if (!mShuffling && index < mMediaList.size() - 1) { mCurrentMedia = mMediaList.get(index + 1); } else { if (mRepeating == RepeatType.All && mMediaList.size() > 0) mCurrentMedia = mMediaList.get(0); else { stop(); return; } } if (mLibVLCPlaylistActive) { if (mRepeating == RepeatType.None) mLibVLC.next(); else if (mRepeating == RepeatType.Once) mLibVLC.playIndex(index); else mLibVLC.playIndex(mMediaList.indexOf(mCurrentMedia)); } else { mLibVLC.readMedia(mCurrentMedia.getLocation(), true); } mHandler.sendEmptyMessage(SHOW_PROGRESS); setUpRemoteControlClient(); showNotification(); updateWidget(this); updateRemoteControlClientMetadata(); saveCurrentMedia(); }
/** @param args the command line arguments */ static String cifrado( String texto, int[] engranaje, int desplazamiento, ArrayList<Character> arrayInterior, ArrayList<Character> arrayExterior) { String resultado = ""; System.out.println(" --- Cifrando ---"); char[] arrayTexto = texto.toCharArray(); int posicionesMovidas = engranaje[desplazamiento]; for (int i = 0; i < texto.length(); i++) { posicionesMovidas = engranaje[desplazamiento]; System.out.println("Letra a cifrar: " + arrayTexto[i]); System.out.println("Desplazamiento: " + desplazamiento); for (int j = 0; j < posicionesMovidas + 4; j++) { arrayInterior.add(0, arrayInterior.get(arrayInterior.size() - 1)); arrayInterior.remove(arrayInterior.size() - 1); } System.out.println( "La letra cifrada es: " + arrayInterior.get(arrayExterior.indexOf(arrayTexto[i]))); resultado += arrayInterior.get(arrayExterior.indexOf(arrayTexto[i])); if (desplazamiento >= 16) desplazamiento = 0; else desplazamiento++; } return resultado; }
public static void main(String[] args) throws IOException { // Use BufferedReader rather than RandomAccessFile; it's much faster BufferedReader f = new BufferedReader(new FileReader("badrand.in")); // input file name goes above PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("badrand.out"))); // Use StringTokenizer vs. readLine/split -- lots faster StringTokenizer st = new StringTokenizer(f.readLine()); // Get line, break into tokens int i1 = Integer.parseInt(st.nextToken()); // first integer ArrayList squares = new ArrayList<Integer>(10000); int mark = 0; i1 = middleSquare(i1); while (i1 > 0) { if (squares.contains(i1)) { squares.add(i1); squares.set(squares.indexOf(i1), 10000); mark = i1; i1 = 0; } else { squares.add(i1); i1 = middleSquare(i1); } } squares.add(10000); squares.add(0); out.println(squares.indexOf(mark) + 1); out.close(); // close the output file System.exit(0); // don't omit this! }
public static void updateUser(String oldName, String username, String password, String name) { User temp = findUser(oldName); if (temp != null) { _users.get(_users.indexOf(temp)).setUsername(username); _users.get(_users.indexOf(temp)).setPassword(password); _users.get(_users.indexOf(temp)).setName(name); } }
public void initUI() { scrollingToBottomCheckbox.setSelected(applicationPreferences.isScrollingToBottom()); coloringWholeRowCheckbox.setSelected(applicationPreferences.isColoringWholeRow()); showFullCallstackCheckbox.setSelected(applicationPreferences.isShowingFullCallstack()); showStackTraceCheckbox.setSelected(applicationPreferences.isShowingStackTrace()); usingWrappedExceptionStyleCheckbox.setSelected( applicationPreferences.isUsingWrappedExceptionStyle()); // look and feel { ArrayList<String> lookAndFeels = new ArrayList<>(); for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { lookAndFeels.add(info.getName()); } Collections.sort(lookAndFeels); int selectedIndex = 0; String lookAndFeel = applicationPreferences.getLookAndFeel(); if (lookAndFeel == null || "".equals(lookAndFeel)) { lookAndFeel = UIManager.getLookAndFeel().getName(); } int idx = lookAndFeels.indexOf(lookAndFeel); if (idx > -1) { selectedIndex = idx; } else { idx = lookAndFeels.indexOf(ApplicationPreferences.STARTUP_LOOK_AND_FEEL); if (idx > -1) { selectedIndex = idx; } } lookAndFeelCombo.setModel( new DefaultComboBoxModel<>(lookAndFeels.toArray(new String[lookAndFeels.size()]))); lookAndFeelCombo.setSelectedIndex(selectedIndex); } // default condition name { List<String> conditionNames = applicationPreferences.retrieveAllConditions(); String defaultName = applicationPreferences.getDefaultConditionName(); int idx = conditionNames.indexOf(defaultName); if (idx < 0) { idx = 0; } defaultConditionCombo.setModel( new DefaultComboBoxModel<>(conditionNames.toArray(new String[conditionNames.size()]))); defaultConditionCombo.setSelectedIndex(idx); } String appPath = applicationPreferences.getApplicationPath().getAbsolutePath(); appPathTextField.setText(appPath); appPathTextField.setToolTipText(appPath); globalLoggingEnabledCheckbox.setSelected(applicationPreferences.isGlobalLoggingEnabled()); loggingStatsEnabledCheckbox.setSelected(applicationPreferences.isLoggingStatisticEnabled()); trayActiveCheckbox.setSelected(applicationPreferences.isTrayActive()); trayActiveCheckbox.setEnabled(TraySupport.isAvailable()); hidingOnCloseCheckbox.setSelected(applicationPreferences.isHidingOnClose()); hidingOnCloseCheckbox.setEnabled(TraySupport.isAvailable()); }
private void parseDirective(String directive) { if (directive == null) { System.err.println("Directive is null."); return; } String[] pair = directive.split("="); if (pair == null || pair.length != 2) { System.err.println("Unable to parse directive: \"" + directive + "\" Ignored."); return; } String key = pair[0].trim(), value = pair[1].trim(); // clean these, might have too much whitespace around commas if (validKeys.indexOf(key) == FONT || validKeys.indexOf(key) == PRELOAD) { value = value.replaceAll("[\\s]*,[\\s]*", ","); } if (validKeys.indexOf(key) == -1) { System.err.println("Directive key not recognized: \"" + key + "\" Ignored."); return; } if (value.equals("")) { System.err.println("Directive value empty. Ignored."); return; } value = value.replaceAll("^\"|\"$", "").replaceAll("^'|'$", ""); // System.out.println( key + " = " + value ); boolean v; switch (validKeys.indexOf(key)) { case CRISP: v = value.toLowerCase().equals("true"); crispBox.setSelected(v); break; case FONT: fontField.setText(value); break; case GLOBAL_KEY_EVENTS: v = value.toLowerCase().equals("true"); globalKeyEventsBox.setSelected(v); break; case PAUSE_ON_BLUR: v = value.toLowerCase().equals("true"); pauseOnBlurBox.setSelected(v); break; case PRELOAD: preloadField.setText(value); break; case TRANSPARENT: v = value.toLowerCase().equals("true"); // transparentBox.setSelected(v); break; } }
public static DefaultCategoryDataset createDatasetForCriterionEvaluationCompareBarChart( List<Fragebogen> fragebogenList) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); ArrayList<Bereich> bereiche = EvaluationHelper.getBereicheFromEvaluationHelper(fragebogenList.get(0).getBewertungen()); for (Fragebogen f : fragebogenList) { double[] values = new double[bereiche.size()]; int valCount = 0; for (Bereich bereich : bereiche) { valCount = 0; for (Bewertung bewertung : f.getBewertungen()) { if (bewertung.getItem() != null) { if (bereich.equals(bewertung.getItem().getBereich())) { if (!bewertung.getWert().isEmpty()) values[bereiche.indexOf(bereich)] += Double.parseDouble(bewertung.getWert()); valCount++; } } } if (valCount != 0) { values[bereiche.indexOf(bereich)] /= valCount; } else { values[bereiche.indexOf(bereich)] = 0; } } ArrayList<Handlungsfeld> hfList = new ArrayList<Handlungsfeld>(); for (Bereich bereich : bereiche) { if (!hfList.contains(bereich.getHandlungsfeld())) { hfList.add(bereich.getHandlungsfeld()); } } for (Handlungsfeld hf : hfList) { double ret = 0; int i = 0; for (Bereich bereich : bereiche) { if (bereich.getHandlungsfeld().equals(hf)) { ret += values[bereiche.indexOf(bereich)]; i++; } } if (i > 0) { ret /= i; } else { ret = 0; } defaultcategorydataset.addValue(ret, f.getPerspektive().getName(), hf.getName()); } } return defaultcategorydataset; }
protected void edgeStmt(StreamTokenizer tk, final int nindex) throws Exception { tk.nextToken(); GraphEdge e = null; if (tk.ttype == '>') { tk.nextToken(); if (tk.ttype == '{') { while (true) { tk.nextToken(); if (tk.ttype == '}') { break; } else { nodeID(tk); e = new GraphEdge(nindex, m_nodes.indexOf(new GraphNode(tk.sval, null)), DIRECTED); if (m_edges != null && !(m_edges.contains(e))) { m_edges.add(e); // System.out.println("Added edge from "+ // ((GraphNode)(m_nodes.get(nindex))).ID+ // " to "+ // ((GraphNode)(m_nodes.get(e.dest))).ID); } } } } else { nodeID(tk); e = new GraphEdge(nindex, m_nodes.indexOf(new GraphNode(tk.sval, null)), DIRECTED); if (m_edges != null && !(m_edges.contains(e))) { m_edges.add(e); // System.out.println("Added edge from "+ // ((GraphNode)(m_nodes.get(nindex))).ID+" to "+ // ((GraphNode)(m_nodes.get(e.dest))).ID); } } } else if (tk.ttype == '-') { System.err.println("Error at line " + tk.lineno() + ". Cannot deal with undirected edges"); if (tk.ttype == StreamTokenizer.TT_WORD) { tk.pushBack(); } return; } else { System.err.println("Error at line " + tk.lineno() + " in edgeStmt"); if (tk.ttype == StreamTokenizer.TT_WORD) { tk.pushBack(); } return; } tk.nextToken(); if (tk.ttype == '[') { edgeAttrib(tk, e); } else { tk.pushBack(); } }
/** * When in two-pane mode, switch to the fragment pane to show the given preference fragment. * * @param header The new header to display. */ public void switchToHeader(Header header) { if (mCurHeader == header) { // This is the header we are currently displaying. Just make sure // to pop the stack up to its root state. getSupportFragmentManager() .popBackStack(BACK_STACK_PREFS, FragmentManager.POP_BACK_STACK_INCLUSIVE); } else { int direction = mHeaders.indexOf(header) - mHeaders.indexOf(mCurHeader); switchToHeaderInner(header.fragment, header.fragmentArguments, direction); setSelectedHeader(header); } }
/** Removes the menu represented by the node */ private void removeVisualMenu(RADMenuItemComponent comp) { Object o = getBeanInstance(); Object m = comp.getBeanInstance(); Object dto = getDesignTimeMenus(getFormManager()).getDesignTime(o); Object dtm = getDesignTimeMenus(getFormManager()).getDesignTime(m); switch (getMenuItemType()) { case T_MENUBAR: ((MenuBar) o).remove((Menu) m); ((JMenuBar) dto).remove((JMenu) dtm); ((JMenuBar) dto).validate(); break; case T_MENU: if (comp.getMenuItemType() == T_SEPARATOR) { ((Menu) o).remove(subComponents.indexOf(comp)); ((JMenu) dto).remove(subComponents.indexOf(comp)); } else { ((Menu) o).remove((MenuItem) m); ((JMenu) dto).remove((JMenuItem) dtm); } break; case T_POPUPMENU: if (comp.getMenuItemType() == T_SEPARATOR) { ((Menu) o).remove(subComponents.indexOf(comp)); // PENDING - dont know how to get reference to JPopupMenu.Separator // so it is not supported by getDesignTimeMenu () !! // ((JPopupMenu)dto).remove((JPopupMenu.Separator)dtm); } else { ((Menu) o).remove((MenuItem) m); ((JPopupMenu) dto).remove((JMenuItem) dtm); } break; case T_JMENUBAR: ((JMenuBar) o).remove((JMenu) m); ((JMenuBar) o).validate(); break; case T_JMENU: if (comp.getMenuItemType() == T_JSEPARATOR) { ((JMenu) o).remove(subComponents.indexOf(comp)); } else { ((JMenu) o).remove((JMenuItem) m); } break; case T_JPOPUPMENU: if (comp.getMenuItemType() == T_JSEPARATOR) { // XXX(-tdt) ((JPopupMenu)o).remove((JPopupMenu.Separator)m); ((JPopupMenu) o).remove(subComponents.indexOf(comp)); } else { ((JPopupMenu) o).remove((JMenuItem) m); } break; } }
// get the nearest of two random Wakeup-Locations public static Location getRandom(Location playerLoc) { if (wakeups.isEmpty()) { return null; } ArrayList<Wakeup> worldWakes = new ArrayList<>(); for (Wakeup wakeup : wakeups) { if (wakeup.active) { if (wakeup.loc.getWorld().equals(playerLoc.getWorld())) { worldWakes.add(wakeup); } } } if (worldWakes.isEmpty()) { return null; } Wakeup w1 = calcRandom(worldWakes); worldWakes.remove(w1); if (w1 == null) return null; while (!w1.check()) { p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w1)); w1 = calcRandom(worldWakes); if (w1 == null) { return null; } worldWakes.remove(w1); } Wakeup w2 = calcRandom(worldWakes); if (w2 != null) { worldWakes.remove(w2); while (!w2.check()) { p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w2)); w2 = calcRandom(worldWakes); if (w2 == null) { return w1.loc; } worldWakes.remove(w2); } if (w1.loc.distance(playerLoc) > w2.loc.distance(playerLoc)) { return w2.loc; } } return w1.loc; }