List of usage examples for java.util Vector isEmpty
public synchronized boolean isEmpty()
From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java
/** * Initialisiere alle Felder, Objekte, die zur grafischen Darstellung gebraucht werden Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * /*from ww w . j a v a 2 s . co m*/ * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 26.06.2012 * @param connDev * Falls verbunden, das aktuelle Gert bergeben (fr Voreinstellungen) * @throws Exception */ @SuppressWarnings("unchecked") public void initGraph(String connDev) throws Exception { // // entsorge fr alle Flle das Zeug von vorher releaseGraph(); if (connDev == null) { lg.debug("init graphic objects whitout active Device"); } else { lg.debug("init graphic objects Device <" + connDev + ">..."); } // // Ist berhaupt eine Datenbank zum Auslesen vorhanden? // if (databaseUtil == null || (!databaseUtil.isOpenDB())) { throw new Exception("no database object initiated!"); } // // Lese eine Liste der Tauchgnge fr dieses Gert // Vector<String[]> entrys = databaseUtil.getAliasDataConn(); if (entrys == null) { lg.warn("no devices found in database."); showWarnBox(LangStrings.getString("spx42LogGraphPanel.warnBox.noDevicesInDatabase")); return; } // // flle deviceComboBox // DeviceComboBoxModel portBoxModel = new DeviceComboBoxModel(entrys); deviceComboBox.setModel(portBoxModel); if (!entrys.isEmpty()) { // wen kein Gert da ist, brauch ich nicht suchen if (connDev != null) { // Alle Eintrge testen int index = 0; for (String[] entr : entrys) { if (entr[0].equals(connDev)) { deviceComboBox.setSelectedIndex(index); lg.debug("device found and set as index fr combobox..."); break; } index++; } } } // // gibt es einen Eintrag in der Combobox mte ja deren entsprechende Liste von // Eintrgen gelesen werden.... // if (deviceComboBox.getSelectedIndex() != -1) { connDev = ((DeviceComboBoxModel) deviceComboBox.getModel()) .getDeviceSerialAt(deviceComboBox.getSelectedIndex()); fillDiveComboBox(connDev); } }
From source file:org.unitime.timetable.solver.exam.ui.ExamInfoModel.java
public String getRoomTable() { try {/*from www .j a v a 2s . com*/ Vector<ExamRoomInfo> rooms = getRooms(); ExamAssignment examAssignment = (iChange == null ? null : iChange.getCurrent(iExam)); Collection<ExamRoomInfo> assigned = (examAssignment != null ? examAssignment.getRooms() : isExamAssigned() ? getExamAssignment().getRooms() : null); Collection<ExamRoomInfo> original = (getExamOldAssignment() != null ? getExamOldAssignment().getRooms() : null); if (rooms == null || rooms.isEmpty()) return ""; Collections.sort(rooms, new Comparator<ExamRoomInfo>() { public int compare(ExamRoomInfo r1, ExamRoomInfo r2) { int cmp = 0; if (ExamInfoForm.sRoomOrdNameAsc.equals(iForm.getRoomOrder())) { cmp = r1.getName().compareTo(r2.getName()); } else if (ExamInfoForm.sRoomOrdNameDesc.equals(iForm.getRoomOrder())) { cmp = -r1.getName().compareTo(r2.getName()); } else if (ExamInfoForm.sRoomOrdSizeAsc.equals(iForm.getRoomOrder())) { cmp = Double.compare(r1.getCapacity(getExam()), r2.getCapacity(getExam())); } else if (ExamInfoForm.sRoomOrdSizeDesc.equals(iForm.getRoomOrder())) { cmp = -Double.compare(r1.getCapacity(getExam()), r2.getCapacity(getExam())); } else { cmp = r1.getName().compareTo(r2.getName()); } if (cmp != 0) return cmp; cmp = r1.getName().compareTo(r2.getName()); ; if (cmp != 0) return cmp; return r1.getLocationId().compareTo(r2.getLocationId()); } }); String ret = ""; ret += "<script language='javascript'>"; ret += "function roomOver(source, id) { "; ret += " document.getElementById('r'+id).style.backgroundColor='rgb(223,231,242)';"; ret += " document.getElementById('c'+id).style.backgroundColor='rgb(223,231,242)';"; ret += " source.style.cursor='hand';source.style.cursor='pointer';"; ret += "}"; ret += "var sCap = -1;"; ret += "var sRooms = '"; if (assigned != null && assigned.size() > 0) { for (ExamRoomInfo room : assigned) { ret += ":" + room.getLocationId() + "@" + room.getCapacity(getExam()); } } ret += "';"; ret += "var sNrRooms = " + (assigned != null ? assigned.size() : 0) + ";"; ret += "function roomSelected(id) {"; ret += " return sRooms.indexOf(':'+id+'@')>=0;"; ret += "}"; ret += "function roomOut(id) { "; ret += " var bg = 'transparent';"; ret += " if (roomSelected(id)) bg='rgb(168,187,225)';"; ret += " document.getElementById('r'+id).style.backgroundColor=bg;"; ret += " document.getElementById('c'+id).style.backgroundColor=bg;"; ret += "}"; ret += "function roomClick(source, id, cap) { "; ret += " if (sCap<0) {"; ret += " sCap = 0; sRooms=''; sNrRooms=0;"; if (assigned != null && assigned.size() > 0) { for (ExamRoomInfo room : assigned) ret += " roomOut(" + room.getLocationId() + ");"; } ret += " }"; ret += " var i = sRooms.indexOf(':'+id+'@');"; ret += " if (i>=0) {"; ret += " var j = sRooms.indexOf(':',i+1);"; ret += " sRooms = sRooms.substring(0, i)+(j>=0?sRooms.substring(j):'');"; ret += " sCap -= cap; sNrRooms--;"; ret += " } else {"; ret += " sRooms = sRooms + ':' + id + '@' + cap;"; ret += " sCap += cap; sNrRooms++;"; ret += " if (sNrRooms>" + getExam().getMaxRooms() + ") {"; ret += " var fid = sRooms.substring(1, sRooms.indexOf('@'));"; ret += " var fcap = sRooms.substring(sRooms.indexOf('@')+1, sRooms.indexOf(':',1));"; ret += " sRooms = sRooms.substring(sRooms.indexOf(':',1));"; ret += " sCap -= fcap; sNrRooms--; roomOut(fid);"; ret += " };"; ret += " }"; ret += " roomOut(id);"; ret += " if (sCap>=" + getExam().getNrStudents() + ") {displayLoading(); document.location='examInfo.do?op=Select&room='+sRooms+'&noCacheTS=" + new Date().getTime() + "';}"; ret += " var c = document.getElementById('roomCapacityCounter');"; ret += " if (c!=null) c.innerHTML = (sCap<" + getExam().getNrStudents() + "?'<font color=\"red\">'+sCap+'</font>':''+sCap);"; ret += "}"; ret += "</script>"; ret += "<table border='0' cellspacing='0' cellpadding='3'>"; int idx = 0; int step = 6; for (ExamRoomInfo room : rooms) { if ((idx % step) == 0) { if (idx > 0) ret += "</tr>"; ret += "<tr>"; } String style = ""; if (assigned != null && assigned.contains(room)) style += "background-color:rgb(168,187,225);"; if (original != null && original.contains(room)) style += "text-decoration:underline;"; String mouse = "onMouseOver=\"roomOver(this," + room.getLocationId() + ");\" " + "onMouseOut=\"roomOut(" + room.getLocationId() + ");\" " + "onClick=\"roomClick(this," + room.getLocationId() + "," + room.getCapacity(getExam()) + ");\""; ret += "<td nowrap id='r" + room.getLocationId() + "' " + (style.length() > 0 ? "style='" + style + "' " : "") + mouse + ">" + room.toString() + "</td>"; if ((idx % step) < step - 1) style += "border-right: #646464 1px dashed;"; ret += "<td id='c" + room.getLocationId() + "' " + (style.length() > 0 ? "style='" + style + "' " : "") + mouse + ">" + room.getCapacity(getExam()) + "</td>"; idx++; } while ((idx % step) != 0) { ret += "<td colspan='2'> </td>"; idx++; } ret += "</tr>"; ret += "</table>"; return ret; } catch (Exception e) { sLog.error(e.getMessage(), e); return ""; } }
From source file:com.google.gsa.Kerberos.java
/** * Sets the kerberos and non-kerberos authentication cookies * /* w ww . j a v a 2s . co m*/ */ private void settingSessionCookies(Vector<Cookie> krbCookies, Vector<Cookie> nonKrbCookies, Cookie gsaAuthCookie, UserSession userSession) { int numKrb = 0; int numNonKrb = 0; int authCookie = 1; Cookie[] totalCookies; //check number of cookies if (!krbCookies.isEmpty()) { numKrb = krbCookies.size(); logger.debug("numKrb: " + numKrb); } if (!nonKrbCookies.isEmpty()) { numNonKrb = nonKrbCookies.size(); logger.debug("numNonKrb: " + numNonKrb); } //setting Cookies int numCookies = numKrb + numNonKrb + authCookie; logger.debug("numCookies: " + numCookies); totalCookies = new Cookie[numCookies]; //setting authCookie logger.debug("Inserting authCoookie at totalCookie"); totalCookies[0] = gsaAuthCookie; int index = 1; //getting Krb cookies if (numKrb > 0) { int krbIndex = 0; for (int i = index; i < (numKrb + 1); i++) { logger.debug("Inserting totalCookie [i=" + (i) + "]"); logger.debug("with cookie: " + krbCookies.elementAt(krbIndex)); totalCookies[i] = krbCookies.elementAt(krbIndex); krbIndex++; index++; } } //getting nonKrb cookies if (numNonKrb > 0) { int nonKrbIndex = 0; for (int j = index; j < numCookies; j++) { logger.debug("Inserting totalCookie [j=" + (j) + "]: "); logger.debug("with cookie: " + nonKrbCookies.elementAt(nonKrbIndex)); totalCookies[j] = nonKrbCookies.elementAt(nonKrbIndex); nonKrbIndex++; } } userSession.setCookies(totalCookies); }
From source file:ffx.ui.KeywordPanel.java
/** * <p>//from ww w. j av a2s . c om * loadActive</p> * * @param newSystem a {@link ffx.ui.FFXSystem} object. * @param newKeys a {@link java.util.Hashtable} object. * @param newKeyFile a {@link java.io.File} object. * @return a boolean. */ public boolean loadActive(FFXSystem newSystem, Hashtable<String, Keyword> newKeys, File newKeyFile) { synchronized (this) { // Store changes made to the current system (if any) first. if (currentKeys != null && KeywordComponent.isKeywordModified()) { if (currentSystem != null && currentSystem != newSystem) { storeActive(); } else { saveChanges(); } } // Clear previous values keyClear(); // No keywords to load if (newKeys == null || newKeys.size() == 0) { return false; } currentSystem = newSystem; currentKeyFile = newKeyFile; currentKeys = newKeys; fileOpen = true; /* * Keys to remove are those entries not recognized by the FFX * Keyword Editor These keys are removed from the active System's * keyword Hashtable and appended to the generic "Comments" * KeywordData instance. */ ArrayList<String> keysToRemove = new ArrayList<>(); Keyword comments = currentKeys.get("COMMENTS"); for (Keyword keyword : currentKeys.values()) { String label = keyword.getKeyword(); Vector<String> data = keyword.getEntries(); if (label.equals("COMMENTS")) { continue; } KeywordComponent tk = keywordHashMap.get(label.toUpperCase()); // If the keyword label isn't recognized, preserve the line // as a Comment if (tk == null) { keysToRemove.add(keyword.getKeyword()); if (data.isEmpty()) { comments.append(label); } else if (label.equalsIgnoreCase("MULTIPOLE")) { int count = 5; for (String entry : data) { count++; if (count > 5) { comments.append(label + " " + entry); count = 1; } else { comments.append(entry); } } } else if (label.equalsIgnoreCase("TORTORS")) { int points = 0; int count = 0; for (String entry : data) { count++; if (count > points) { String res[] = entry.split(" +"); int xres = Integer.parseInt(res[5]); int yres = Integer.parseInt(res[5]); points = xres * yres; comments.append(label + " " + entry); count = 0; } else { comments.append(entry); } } } else { for (String entry : data) { comments.append(label + " " + entry); } } continue; } // No data for this keyword (something like "verbose" that // doesn't have modifiers) if (data.isEmpty()) { tk.loadKeywordEntry(label); } // One to many data entries (something "atom" or "bond" that // can be repeated) for (String s : data) { tk.loadKeywordEntry(s); } } // Load up the Comments Vector<String> entries = comments.getEntries(); if (entries != null) { for (String s : entries) { if (s.length() > 1) { if (!groupHashMap.containsKey(s.substring(1).toUpperCase().trim())) { commentStringBuffer.append(s).append("\n"); } } else { commentStringBuffer.append(s).append("\n"); } } } // Keywords that aren't recognized have been turned into Comments for (String k : keysToRemove) { currentKeys.remove(k); } if (currentSystem != null) { currentSystem.setKeywords(currentKeys); currentSystem.setKeyFile(currentKeyFile); } loadKeywordGroup(); return true; } }
From source file:edu.umn.cs.spatialHadoop.nasa.StockQuadTree.java
/** * Perform a selection query that retrieves all points in the given range. * The range is specified in the two-dimensional array positions. * @param in// ww w. j a va 2s .c om * @param query_mbr * @return * @throws IOException */ public static Node aggregateQuery(FSDataInputStream in, Rectangle query_mbr) throws IOException { long treeStartPosition = in.getPos(); Node result = new Node(); int numOfSelectedRecords = 0; int resolution = in.readInt(); short fillValue = in.readShort(); int cardinality = in.readInt(); final Vector<Integer> selectedNodesPos = new Vector<Integer>(); final Vector<Integer> selectedStarts = new Vector<Integer>(); final Vector<Integer> selectedEnds = new Vector<Integer>(); StockQuadTree stockQuadTree = getOrCreateStockQuadTree(resolution); // Nodes to be searched. Contains node positions in the array of nodes Stack<Integer> nodes_2b_searched = new Stack<Integer>(); nodes_2b_searched.add(0); // Root node (ID=1) Rectangle node_mbr = new Rectangle(); while (!nodes_2b_searched.isEmpty()) { int node_pos = nodes_2b_searched.pop(); stockQuadTree.getNodeMBR(node_pos, node_mbr); if (query_mbr.contains(node_mbr)) { // Add this node to the selection list and stop this branch selectedNodesPos.add(node_pos); } else if (query_mbr.intersects(node_mbr)) { int first_child_id = stockQuadTree.nodesID[node_pos] * 4 + 0; int first_child_pos = Arrays.binarySearch(stockQuadTree.nodesID, first_child_id); if (first_child_pos < 0) { // No children. Hit a leaf node // Scan and add matching points only java.awt.Point record_coords = new Point(); for (int record_pos = stockQuadTree.nodesStartPosition[node_pos]; record_pos < stockQuadTree.nodesEndPosition[node_pos]; record_pos++) { stockQuadTree.getRecordCoords(record_pos, record_coords); if (query_mbr.contains(record_coords)) { // matched a record. if (!selectedEnds.isEmpty() && selectedEnds.lastElement() == record_pos) { // Merge with an adjacent range selectedEnds.set(selectedEnds.size() - 1, record_pos + 1); } else { // Add a new range of unit width selectedStarts.add(record_pos); selectedEnds.add(record_pos + 1); } numOfSelectedRecords++; } } } else { // Non-leaf node. Add all children to the list of nodes to search // Add in reverse order to the stack so that results come in sorted order nodes_2b_searched.add(first_child_pos + 3); nodes_2b_searched.add(first_child_pos + 2); nodes_2b_searched.add(first_child_pos + 1); nodes_2b_searched.add(first_child_pos + 0); } } } // Result 1: Accumulate all values // Sort disk offsets to eliminate backward seeks if (!selectedStarts.isEmpty()) { LOG.debug("Aggregate query selected " + selectedNodesPos.size() + " nodes and " + numOfSelectedRecords + " records"); final IndexedSortable sortable = new IndexedSortable() { @Override public int compare(int i, int j) { return selectedStarts.get(i) - selectedStarts.get(j); } @Override public void swap(int i, int j) { int temp = selectedStarts.get(i); selectedStarts.set(i, selectedStarts.get(j)); selectedStarts.set(j, temp); temp = selectedEnds.get(i); selectedEnds.set(i, selectedEnds.get(j)); selectedEnds.set(j, temp); } }; new QuickSort().sort(sortable, 0, selectedStarts.size()); long dataStartPosition = getValuesStartOffset(cardinality); Point resultCoords = new Point(); // Return all values in the selected ranges for (int iRange = 0; iRange < selectedStarts.size(); iRange++) { int treeStart = selectedStarts.get(iRange); int treeEnd = selectedEnds.get(iRange); long startPosition = dataStartPosition + selectedStarts.get(iRange) * cardinality * 2; in.seek(startPosition); for (int treePos = treeStart; treePos < treeEnd; treePos++) { // Retrieve the coords for the point at treePos stockQuadTree.getRecordCoords(treePos, resultCoords); // Read all entries at current position for (int iValue = 0; iValue < cardinality; iValue++) { short value = in.readShort(); if (value != fillValue) result.accumulate(value); } } } } // Result 2: Accumulate all nodes if (!selectedNodesPos.isEmpty()) { long nodesStartPosition = treeStartPosition + getNodesStartOffset(resolution, cardinality); // Sort node positions to eliminate backward seeks IndexedSortable nodeSortable = new IndexedSortable() { @Override public int compare(int i, int j) { return selectedNodesPos.get(i) - selectedNodesPos.get(j); } @Override public void swap(int i, int j) { int temp = selectedNodesPos.get(i); selectedNodesPos.set(i, selectedNodesPos.get(j)); selectedNodesPos.set(j, temp); } }; new QuickSort().sort(nodeSortable, 0, selectedNodesPos.size()); Node selectedNode = new Node(); for (int node_pos : selectedNodesPos) { long nodePosition = nodesStartPosition + node_pos * NodeSize; in.seek(nodePosition); selectedNode.readFields(in); result.accumulate(selectedNode); } } return result; }
From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java
/** * Zeichne die eigentliche Grafik Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * //from w w w.j ava 2 s . com * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 03.07.2012 * @param dbId * dbid in Tabelle D_TABLE_DIVEDETAIL * @param device */ private void makeGraphForLog(int dbId, String device) { Vector<Integer[]> diveList; Vector<String> diluents; int[] headData; XYPlot thePlot; JFreeChart logChart; int min, sec; // das alte Zeug entsorgen releaseGraph(); // // Daten eines TG lesen // lg.debug("read dive log from DB..."); diveList = databaseUtil.getDiveDataFromIdLog(dbId); if (diveList == null || diveList.isEmpty()) { return; } // // verwendete Diluents finden // diluents = getDiluentNamesFromDive(diveList); // Anzeigen String diluentString = StringUtils.join(diluents, ", "); diluentLabel.setText( String.format(LangStrings.getString("spx42LogGraphPanel.diluentLabel.text"), diluentString)); lg.debug(diluents); // // Labels fr Tachgangseckdaten fllen // headData = databaseUtil.getHeadDiveDataFromIdLog(dbId); notesLabel.setText(databaseUtil.getNotesForIdLog(dbId)); showingUnitSystem = SpxPcloggerProgramConfig.unitsProperty; savedUnitSystem = headData[6]; // jetzt die Strings fr Masseinheiten holen String[] labels = getUnitsLabel(showingUnitSystem, savedUnitSystem); depthUnitName = labels[0]; tempUnitName = labels[1]; pressureUnitName = labels[2]; // // entscheide ob etwas umgerechnet werden sollte // if (showingUnitSystem == savedUnitSystem || showingUnitSystem == ProjectConst.UNITS_DEFAULT) { // nein, alles schick maxDepthValueLabel.setText(String.format(maxDepthLabelString, (headData[3] / 10.0), depthUnitName)); coldestTempValueLabel.setText(String.format(coldestLabelString, (headData[2] / 10.0), tempUnitName)); } else { // umrechnen! if (showingUnitSystem == ProjectConst.UNITS_IMPERIAL) { // metrisch-> imperial konvertieren // 1 foot == 30,48 cm == 0.3048 Meter maxDepthValueLabel .setText(String.format(maxDepthLabelString, (headData[3] / 10.0) / 0.3048, depthUnitName)); // t F = 5?9 (t 32) C coldestTempValueLabel.setText( String.format(coldestLabelString, (5.0 / 9.0) * ((headData[2] / 10.0) - 32), tempUnitName)); } else { maxDepthValueLabel .setText(String.format(maxDepthLabelString, (headData[3] / 10.0) * 0.3048, depthUnitName)); // t C = (9?5 t + 32) F coldestTempValueLabel.setText( String.format(coldestLabelString, ((9.0 / 5.0) * (headData[2] / 10.0)) + 32, tempUnitName)); } } min = headData[5] / 60; sec = headData[5] % 60; diveLenValueLabel.setText(String.format(diveLenLabelString, min, sec, "min")); // // einen Plot machen (Grundlage des Diagramms) // lg.debug("create graph..."); thePlot = new XYPlot(); // // Eigenschaften definieren // thePlot.setBackgroundPaint(Color.lightGray); thePlot.setDomainGridlinesVisible(true); thePlot.setDomainGridlinePaint(Color.white); thePlot.setRangeGridlinesVisible(true); thePlot.setRangeGridlinePaint(Color.white); thePlot.setDomainPannable(true); thePlot.setRangePannable(false); // // ein Chart zur Anzeige in einem Panel erzeugen // logChart = new JFreeChart(LangStrings.getString("spx42LogGraphPanel.graph.chartTitle"), thePlot); logChart.setAntiAlias(true); logChart.addSubtitle(new TextTitle(LangStrings.getString("spx42LogGraphPanel.graph.chartSubTitle"))); // ein Thema zufgen, damit ich eigene Farben einbauen kann ChartUtilities.applyCurrentTheme(logChart); // // ein Diagramm-Panel erzeugen // chartPanel = new ChartPanel(logChart); chartPanel.setMouseZoomable(true); chartPanel.setAutoscrolls(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setRangeZoomable(false); chartPanel.setDisplayToolTips(false); chartPanel.setZoomTriggerDistance(10); add(chartPanel, BorderLayout.CENTER); // // Datumsachse umformatieren // final NumberAxis axis = new NumberAxis(LangStrings.getString("spx42LogGraphPanel.graph.dateAxisTitle")); MinuteFormatter formatter = new MinuteFormatter( LangStrings.getString("spx42LogGraphPanel.graph.dateAxisUnit")); axis.setNumberFormatOverride(formatter); thePlot.setDomainAxis(axis); // // Temperatur einfgen // if (SpxPcloggerProgramConfig.showTemperature) { makeTemperatureGraph(diveList, thePlot, labels); } // // Partialdruck einfgen // die Achse erst mal machen final NumberAxis ppo2Axis = new NumberAxis( LangStrings.getString("spx42LogGraphPanel.graph.ppo2AxisTitle") + " " + pressureUnitName); final NumberAxis percentAxis = new NumberAxis(LangStrings.getString("spx42LogGraphPanel.graph.inertgas")); // // wenn eine der Achsen dargesstellt werden muss, dann sollte die Achse auch in der Grafil da sein // if (SpxPcloggerProgramConfig.showPpo01 || SpxPcloggerProgramConfig.showPpo02 || SpxPcloggerProgramConfig.showPpo03 || SpxPcloggerProgramConfig.showPpoResult || SpxPcloggerProgramConfig.showSetpoint) { ppo2Axis.setAutoRangeIncludesZero(false); ppo2Axis.setAutoRange(false); // // wie skaliere ich die Achse? // if (showingUnitSystem == ProjectConst.UNITS_DEFAULT) { // so wie gespeichert if (savedUnitSystem == ProjectConst.UNITS_METRIC) { ppo2Axis.setRange(0.0, 3.5); } else { ppo2Axis.setRange(0.0, (3.5 * 14.504)); } } else if (showingUnitSystem == ProjectConst.UNITS_METRIC) { ppo2Axis.setRange(0.0, 3.5); } else { ppo2Axis.setRange(0.0, (3.5 * 14.504)); } ppo2Axis.setLabelPaint(new Color(ProjectConst.GRAPH_PPO2ALL_ACOLOR)); ppo2Axis.setTickLabelPaint(new Color(ProjectConst.GRAPH_PPO2ALL_ACOLOR)); thePlot.setRangeAxis(GRAPH_PPO2ALL, ppo2Axis); } if (SpxPcloggerProgramConfig.showHe || SpxPcloggerProgramConfig.showN2) { percentAxis.setAutoRangeIncludesZero(false); percentAxis.setAutoRange(false); percentAxis.setRange(0.0, 100.0); percentAxis.setLabelPaint(new Color(ProjectConst.GRAPH_INNERTGAS_ACOLOR)); percentAxis.setTickLabelPaint(new Color(ProjectConst.GRAPH_INNERTGAS_ACOLOR)); thePlot.setRangeAxis(GRAPH_HE, percentAxis); } // // Partialdrcke der einzelnen Sensoren einfgen // // Sensor 01 anzeigen if (SpxPcloggerProgramConfig.showPpo01) { makePpoGraph(diveList, thePlot, 1); } // Sensor 02 anzeigen if (SpxPcloggerProgramConfig.showPpo02) { makePpoGraph(diveList, thePlot, 2); } // Sensor 03 anzeigen if (SpxPcloggerProgramConfig.showPpo03) { makePpoGraph(diveList, thePlot, 3); } // Resultierenden PPO anzeigen if (SpxPcloggerProgramConfig.showPpoResult) { makePpoGraph(diveList, thePlot, 0); // makePpoResultGraph( diveList, thePlot ); } if (SpxPcloggerProgramConfig.showSetpoint) { makeSetpointGraph(diveList, thePlot); } // // Helium und Stickstoffanteil im Gas? // if (SpxPcloggerProgramConfig.showHe) { makeInnertGasGraph(diveList, thePlot, "he"); } if (SpxPcloggerProgramConfig.showN2) { makeInnertGasGraph(diveList, thePlot, "n2"); } // // die Nullzeit auf Wunsch // if (SpxPcloggerProgramConfig.showNulltime) { makeNulltimeGraph(diveList, thePlot); } // // die Tiefe einfgen // makeDepthGraph(diveList, thePlot); // showingDbIdForDiveWasShowing = dbId; lg.debug("create graph...OK"); }
From source file:org.zywx.wbpalmstar.plugin.uexzxing.qrcode.decoder.DecodedBitStreamParser.java
static DecoderResult decode(byte[] bytes, Version version, ErrorCorrectionLevel ecLevel, Hashtable hints) throws FormatException { BitSource bits = new BitSource(bytes); StringBuffer result = new StringBuffer(50); CharacterSetECI currentCharacterSetECI = null; boolean fc1InEffect = false; Vector byteSegments = new Vector(1); Mode mode;//from w w w . j av a 2 s . c om do { // While still another segment to read... if (bits.available() < 4) { // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here mode = Mode.TERMINATOR; } else { try { mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits } catch (IllegalArgumentException iae) { throw FormatException.getFormatInstance(); } } if (!mode.equals(Mode.TERMINATOR)) { if (mode.equals(Mode.FNC1_FIRST_POSITION) || mode.equals(Mode.FNC1_SECOND_POSITION)) { // We do little with FNC1 except alter the parsed result a bit according to the spec fc1InEffect = true; } else if (mode.equals(Mode.STRUCTURED_APPEND)) { // not really supported; all we do is ignore it // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue bits.readBits(16); } else if (mode.equals(Mode.ECI)) { // Count doesn't apply to ECI int value = parseECIValue(bits); currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); if (currentCharacterSetECI == null) { throw FormatException.getFormatInstance(); } } else { // How many characters will follow, encoded in this mode? int count = bits.readBits(mode.getCharacterCountBits(version)); if (mode.equals(Mode.NUMERIC)) { decodeNumericSegment(bits, result, count); } else if (mode.equals(Mode.ALPHANUMERIC)) { decodeAlphanumericSegment(bits, result, count, fc1InEffect); } else if (mode.equals(Mode.BYTE)) { decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints); } else if (mode.equals(Mode.KANJI)) { decodeKanjiSegment(bits, result, count); } else { throw FormatException.getFormatInstance(); } } } } while (!mode.equals(Mode.TERMINATOR)); return new DecoderResult(bytes, result.toString(), byteSegments.isEmpty() ? null : byteSegments, ecLevel); }
From source file:edu.umn.cs.spatialHadoop.OperationsParams.java
/** * Auto detect shape type based on input format * //from w w w. java 2 s . c om * @return <code>true</code> if a shape is already present in the * configuration or it is auto detected from input files. * <code>false</code> if it was not set and could not be detected. */ public boolean autoDetectShape() { String autoDetectedShape = null; final Vector<String> sampleLines = new Vector<String>(); if (this.get("shape") != null) return true; // A shape is already configured if (this.getInputPaths().length == 0) return false; // No shape is configured and no input to detected try { // Read a random sample from the input // We read a sample instead of one line to make sure // the auto detected shape is consistent in many lines final int sampleCount = 10; OperationsParams sampleParams = new OperationsParams(this); try { LocalSampler.sampleLocal(this.getInputPaths(), sampleCount, new ResultCollector<Text>() { @Override public void collect(Text line) { sampleLines.add(line.toString()); } }, sampleParams); } catch (InterruptedException e1) { e1.printStackTrace(); } if (sampleLines.isEmpty()) { LOG.warn("No input to detect in '" + this.getInputPath() + "-"); return false; } // Collect some stats about the sample to help detecting shape type final String Separators[] = { ",", "\t" }; int[] numOfSplits = { 0, 0 }; // Number of splits with each separator boolean allNumericAllLines = true; // Whether or not all values are numbers int ogcIndex = -1; // The index of the column with OGC data for (String sampleLine : sampleLines) { // This flag is raised if all splits are numbers with one separator boolean allNumericCurrentLine = false; // Try to parse with commas and tabs for (int iSeparator = 0; iSeparator < Separators.length; iSeparator++) { String separator = Separators[iSeparator]; String[] parts = sampleLine.split(separator); if (numOfSplits[iSeparator] == 0) numOfSplits[iSeparator] = parts.length; else if (numOfSplits[iSeparator] != parts.length) numOfSplits[iSeparator] = -1; boolean allNumericCurrentLineCurrentSeparator = true; for (int i = 0; i < parts.length; i++) { String part = parts[i]; if (allNumericCurrentLineCurrentSeparator) { try { Double.parseDouble(part); } catch (NumberFormatException e) { allNumericCurrentLineCurrentSeparator = false; } } try { TextSerializerHelper.consumeGeometryJTS(new Text(part), '\0'); // Reaching this point means the geometry was parsed successfully if (ogcIndex == -1) ogcIndex = i; else if (ogcIndex != i) ogcIndex = -2; } catch (Exception e) { // Couldn't parse OGC for this column } } if (allNumericCurrentLineCurrentSeparator) allNumericCurrentLine = true; } // One line does not have all numeric fields if (!allNumericCurrentLine) allNumericAllLines = false; } if (numOfSplits[0] != -1 && allNumericAllLines) { // Each line is comma separated and all values are numbers if (numOfSplits[0] == 2) { // Point autoDetectedShape = "point"; } else if (numOfSplits[0] == 4) { // Rectangle autoDetectedShape = "rect"; } } else if (ogcIndex >= 0) { // There is a column with geometry stored in it this.setInt("column", ogcIndex); int numOfColumns = 0; for (int iSeparator = 0; iSeparator < Separators.length; iSeparator++) { if (numOfSplits[iSeparator] != -1) { this.set("separator", Separators[iSeparator]); numOfColumns = numOfSplits[iSeparator]; } } if (numOfColumns == 1 && ogcIndex == 0) autoDetectedShape = OGCJTSShape.class.getName(); else autoDetectedShape = CSVOGC.class.getName(); } } catch (IOException e) { } if (autoDetectedShape == null) { LOG.warn("Cannot detect shape for input '" + sampleLines.get(0) + "'"); return false; } else { LOG.info("Autodetected shape '" + autoDetectedShape + "' for input '" + sampleLines.get(0) + "'"); this.set("shape", autoDetectedShape); return true; } }
From source file:ORG.oclc.os.SRW.SRWDatabase.java
public ScanResponseType doRequest(ScanRequestType request) throws ServletException { searchRequest = null;/*from w ww. java 2 s .c o m*/ response = null; ScanResponseType scanResponse = new ScanResponseType(); String version = request.getVersion(); if (version != null && !version.equals("1.1")) return diagnostic(SRWDiagnostic.UnsupportedVersion, version, scanResponse); CQLTermNode root = null; int max = maxTerms, pos = position; long startTime = System.currentTimeMillis(); PositiveInteger pi = request.getMaximumTerms(); if (pi != null) { max = pi.intValue(); pos = max / 2 + 1; } NonNegativeInteger nni = request.getResponsePosition(); if (nni != null) pos = nni.intValue(); String scanTerm = request.getScanClause(); try { if (scanTerm != null) log.info("scanTerm:\n" + Utilities.byteArrayToString(scanTerm.getBytes("UTF-8"))); } catch (Exception e) { } log.info("maxTerms=" + max + ", position=" + pos); try { root = Utilities.getFirstTerm(parser.parse(scanTerm)); } catch (CQLParseException e) { log.error(e); return diagnostic(SRWDiagnostic.QuerySyntaxError, e.getMessage(), scanResponse); } catch (IOException e) { log.error(e); return diagnostic(SRWDiagnostic.QuerySyntaxError, e.getMessage(), scanResponse); } if (root.getTerm().length() == 0) // The method getQualifier() was replaced by getIndex() in version // 1.0 of the parser. This code ensures that either one works. //root = new CQLTermNode(root.getQualifier(), root.getRelation(), "$"); root = new CQLTermNode(SRWSoapBindingImpl.getQualifier(root), root.getRelation(), "$"); String resultSetID = root.getResultSetName(); if (resultSetID != null) { // you can't scan on resultSetId! return diagnostic(SRWDiagnostic.UnsupportedIndex, "cql.resultSetId", scanResponse); } TermsType terms = new TermsType(); TermList tl = getTermList(root, pos, max, request); terms.setTerm(tl.getTerms()); scanResponse.setTerms(terms); Vector<DiagnosticType> diagnostics = tl.getDiagnostics(); if (diagnostics != null && !diagnostics.isEmpty()) { DiagnosticType diagArray[] = new DiagnosticType[diagnostics.size()]; diagnostics.toArray(diagArray); scanResponse.setDiagnostics(new DiagnosticsType(diagArray)); } log.info("scan " + scanTerm + ": (" + (System.currentTimeMillis() - startTime) + "ms)"); return scanResponse; }
From source file:edu.ku.brc.specify.tasks.DataEntryTask.java
/** * @param stdList// w w w .j a va2s .com * @param miscList */ protected void buildNavBoxes(final Vector<DataEntryView> stdList, final Vector<DataEntryView> miscList, final boolean doRegister) { buildFormNavBoxes(stdList, doRegister); if (miscList != null && !miscList.isEmpty()) { availMiscViews.clear(); for (DataEntryView dev : miscList) { ViewIFace view = AppContextMgr.getInstance().getView(null, dev.getView()); if (view != null) { DBTableInfo tableInfo = DBTableIdMgr.getInstance().getByClassName(view.getClassName()); dev.setTableInfo(tableInfo); if (AppContextMgr.isSecurityOn()) { if (!tableInfo.getPermissions().canView()) { continue; } } } availMiscViews.add(dev); } if (availMiscViews.size() > 0) { initDataEntryViews(availMiscViews, doRegister); NavBoxItemIFace nbi = NavBox.createBtnWithTT(getResourceString("DET_MISC_FORMS"), "MoreForms", getResourceString("DET_CHOOSE_TT"), IconManager.STD_ICON_SIZE, createMiscActionListener()); NavBoxButton roc = (NavBoxButton) nbi; for (DataEntryView dev : availMiscViews) { if (dev.getTableInfo() != null) { roc.addDropDataFlavor(new DataFlavorTableExt(DataEntryTask.class, RecordSetTask.RECORD_SET, dev.getTableInfo().getTableId())); } } viewsNavBox.add(nbi); } } }