private void nijmegenNaarHaag() { List<Station> route = netwerk.route(14, 10); System.out.println("De kortste route van Nijmegen naar Den Haag is:"); for (Station i : route) { System.out.println(i.toString()); } }
/** 当单击单元格出现CellEditor时应该显示什么值。由此方法决定, 返回单元格的当前值 返回某个属性的值 */ public Object getValue(Object element, String property) { Object result = null; Station station = (Station) element; if (station == null) return null; // 使用别名的方法 if (property.equals("name")) return station.getStation_name(); else if (property.equals("down")) return String.valueOf(station.getStation_downnumber()); else if (property.equals("up")) return String.valueOf(station.getStation_upnumber()); else if (property.equals("map")) // ComboBoxCellEditor要求返回下拉框中的索引值 return new Integer(getNameIndex(station.getStation_graph())); // 直接使用索引 /* List list = Arrays.asList(stationData.columnHeads); int columnIndex = list.indexOf(property); //再返回对应的数据 switch (columnIndex) { case 0://id return String.valueOf(station.getStation_id()); case 1://name return station.getStation_name(); case 2://down return String.valueOf(station.getStation_downnumber()); case 3://up return String.valueOf(station.getStation_upnumber()); case 4://map ,因为用的是下拉框,所以要返回一个Integer表示当前选中的index return new Integer(getNameIndex(station.getStation_graph())); } */ return result; }
private List<Station> getDataSet(String startTime, String endTime) { List<Station> listStation = new ArrayList<Station>(); try { // Connecting the database Connection cn = DB.getConn(); System.out.println("Searching.."); String sql = "select AVG(nbBikes) as vc,BIXI.station_id,BIXI_STATIONS.station_name,BIXI.datetime from BIXI INNER JOIN BIXI_STATIONS ON BIXI.station_id = BIXI_STATIONS.station_id WHERE BIXI.datetime >= timestamp('" + startTime + "') and BIXI.datetime <= timestamp('" + endTime + "')GROUP BY station_name order by vc desc limit 10"; PreparedStatement ps = cn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); System.out.println("End"); while (rs.next()) { Station station = new Station(); station.setVc(rs.getInt(1)); station.setStation_id(rs.getInt(2)); station.setStation_name(rs.getString(3)); station.setDatatime(new java.util.Date(rs.getDate(4).getTime())); listStation.add(station); } } catch (Exception e) { e.printStackTrace(); } return listStation; }
public static void main(String[] args) { // Read in configuration WaterTreatmentPlantConfiguration waterPlantConfiguration; try { waterPlantConfiguration = new WaterTreatmentPlantConfiguration(); } catch (IOException e) { // Stop completely if we can't get a proper configuration throw new RuntimeException(e.getMessage()); } // Build stations and pipes List<Station> stations = buildStations(waterPlantConfiguration.getNumStations()); List<Pipe> pipes = buildPipes(waterPlantConfiguration.getNumPipes()); // Build runnable station controllers List<StationController> stationControllers = new ArrayList<>(); for (Station station : stations) { stationControllers.add( new StationController( station, pipes, waterPlantConfiguration.getWorkLoads().get(station.getStationNumber()))); } // Run all threads for (StationController controller : stationControllers) { (new Thread(controller)).start(); } }
public void loadFromFile() throws IOException { InputStream fis = new FileInputStream(basePath + slh_filename); InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8")); BufferedReader br = new BufferedReader(isr); String line; int counter = 0; while ((line = br.readLine()) != null) { String[] args = line.split(";"); Station station = new Station(args[0], args[1]); try { station.lantitude = Double.valueOf(args[2]); } catch (NumberFormatException nfe) { station.lantitude = null; } try { station.longtitude = Double.valueOf(args[3]); } catch (NumberFormatException nfe) { station.longtitude = null; } stationList.add(station); counter++; } br.close(); System.out.println("stationList = " + stationList); System.out.println("counter = " + counter); }
protected void setToolTip() { TileI currentTile = orUIManager.getGameUIManager().getGameManager().getTileManager().getTile(internalId); StringBuffer tt = new StringBuffer("<html>"); tt.append("<b>Tile</b>: ").append(currentTile.getName()); // or // getId() if (currentTile.hasStations()) { // for (Station st : currentTile.getStations()) int cityNumber = 0; // TileI has stations, but for (Station st : currentTile.getStations()) { cityNumber++; // = city.getNumber(); tt.append("<br> ") .append(st.getType()) .append(" ") .append(cityNumber) // .append("/").append(st.getNumber()) .append(": value "); tt.append(st.getValue()); if (st.getBaseSlots() > 0) { tt.append(", ").append(st.getBaseSlots()).append(" slots"); } } } tt.append("</html>"); toolTip = tt.toString(); }
public void init() { stations = new ArrayList<>(); for (int i = 0; i < 10; i++) { Station station = new Station(); station.setName("station " + i); stations.add(station); } }
/** * Get station with given id or null if no such station is found in this manager * * @param id the id of this station * @return station with given id or null if no such station is found */ public Station getStationWithId(String id) { Station station = null; for (Station this_station : stations) { if (this_station.getID().equals(id)) { station = this_station; } } return station; }
public static boolean isCurrentStCheapest(ArrayList<Station> sList, Station current) { int currentValue = current.getCost(); for (Station s : sList) { if (s.getCost() < currentValue) { return false; } } return true; }
/** * Returns a HashMap between station names and latitude-longitude coordinates. * * @return A HashMap<String, LatLng> station mapping */ public HashMap<String, LatLng> getStationLatLngMap() { HashMap<String, LatLng> stationMap = new HashMap<>(); for (Station s : mBService.getStations()) { Double sLat = Double.parseDouble(s.getLatitude()); Double sLng = Double.parseDouble(s.getLongitude()); stationMap.put(s.getName(), new LatLng(sLat, sLng)); } return stationMap; }
@Override protected void saveLazyResources(BPMemoryOutputStream lazy) throws IOException { ensureLoaded(); // lazy junction resources lazy.writeString(getName()); lazy.writeInt(stations.size()); for (Station s : stations) { lazy.writeObjectId(s.getId()); } }
private String[] getStationArray() { int index = 0; int size = this.stations.size(); String[] array = new String[size]; for (Station s : this.stations) { array[(index++)] = s.toString(); } return array; }
public Station getStationByID(String id) { if (id == null) throw new NullPointerException(); for (Station station : stations) { if (station.getId().equals(id)) { System.out.println("Bahnhof mit der ID " + id + ": " + station.getName()); return station; } } System.out.println(id + " seems to be NO station!"); return null; }
/** * Find nearest station to given point. Returns null if no station is closer than RADIUS metres. * If two or more stations are at an equal distance from the given point, any one of those * stations is returned. * * @param pt point to which nearest station is sought * @return station closest to pt but less than 10,000m away; null if no station is within RADIUS * metres of pt */ public Station findNearestTo(LatLon pt) { Station NearestStation = null; double NearestDistance = RADIUS; for (Station next_staion : stations) { double distance = SphericalGeometry.distanceBetween(next_staion.getLocn(), pt); if (distance <= RADIUS && distance < NearestDistance) { NearestDistance = distance; NearestStation = next_staion; } } return NearestStation; }
private Station readHeaderStation(int offset) { int nameLoc = readShort(offset); if (nameLoc == 0) return null; Station ret = new Station(); ret.name = strings.get(nameLoc); ret.x = readLong(offset + 6); ret.y = readLong(offset + 10); return ret; }
public Observable<StationMeasurements> getMeasurements(final Station station) { Timber.d("loading station " + station.getGaugeId()); return dataApi .getObjectAttribute(PEGEL_ALARM_SOURCE_ID, station.getGaugeId(), "") .flatMap( new Func1<JsonNode, Observable<StationMeasurements>>() { @Override public Observable<StationMeasurements> call(JsonNode data) { return Observable.just(parseMeasurements(station, data)); } }); }
public void setAdvancedValues() { // get pretty ranges for the current parameters // get the range for the station value double min = 10000; double max = 0; for (int fc = 0; fc < mFileViewer.mNumOpenFiles; fc++) { OpenDataFile of = (OpenDataFile) mFileViewer.mOpenFiles.elementAt(fc); for (int sec = 0; sec < of.mNumSections; sec++) { Section sech = (Section) of.mSections.elementAt(sec); if (sech.mNumCasts == 0) { continue; } for (int stc = 0; stc < sech.mStations.size(); stc++) { Station sh = (Station) sech.mStations.elementAt(stc); if (!sh.mUseStn) { continue; } // get the station value double y = sh.getStnValue(mSelYParam); if (y == JOAConstants.MISSINGVALUE || y >= JOAConstants.EPICMISSINGVALUE) { continue; } else { min = y < min ? y : min; max = y > max ? y : max; } } } } Triplet newRange = JOAFormulas.GetPrettyRange(min, max); double yMinv = newRange.getVal1(); double yMaxv = newRange.getVal2(); double yIncv = newRange.getVal3(); yMin.setText(JOAFormulas.formatDouble(String.valueOf(yMinv), 3, false)); yMax.setText(JOAFormulas.formatDouble(String.valueOf(yMaxv), 3, false)); yInc.setText(JOAFormulas.formatDouble(String.valueOf(yIncv), 3, false)); yTics.setValue(new Integer(yTicsVal)); if (b1.isSelected()) { mOffset = JOAConstants.PROFSEQUENCE; setXRangeToSequence(); } else if (b2.isSelected()) { mOffset = JOAConstants.PROFDISTANCE; setXRangeToDistance(); } else if (b3.isSelected()) { mOffset = JOAConstants.PROFTIME; setXRangeToTime(); } }
private void _renderParentStartIconBlock( FacesContext context, RenderingContext arc, UIXProcess process, Train train) throws IOException { assert train.getParentTrain().hasParentStart(); Station parent = train.getParentTrain().getParentStart(); process.setRowKey(parent.getRowKey()); _renderStationIconBlock(context, arc, process, parent); // Restore model process.setRowKey(train.getInitialRowKey()); }
public void run() { Station currentStation; int amountPartE; while (true) { for (int i = 0; i < stations.size(); i++) { currentStation = stations.get(i); if (currentStation.getPartE() > 0) { amountPartE = currentStation.getPartE(); currentStation.removePartE(amountPartE); System.out.println(currentStation.getName() + " sends " + amountPartE + " P_E"); } } } }
/** * Get a station to put in the database * * @param id for the station * @param warehouse for the station * @return station */ public Station getStation(int id, Warehouse warehouse) { Station station = new Station(); station.setStationID(id); station.setWarehouseID(warehouse.getWarehouseID()); station.setName("Station #" + id); station.setAddress(randAddress()); station.setCity(cities.get(randInt(0, cities.size()))); station.setState(states.get(randInt(0, states.size()))); station.setZip(zips.get(randInt(0, zips.size()))); station.setSalesTax(new BigDecimal(randDouble(minSalesTax, maxSalesTax))); station.setTotalSales(new BigDecimal(0)); return station; }
/** * Finds the closest station to an actor. * * @param actor Actor to which to search for the closest station. * @return Closest station. Null if no stations remaining. */ public Station getClosestStation(Actor actor) { Station with_lowest_distance = null; float lowest_distance = Float.MAX_VALUE; for (Station station : stations) { if (station == null) continue; float distance = station.distance(actor); if (distance < lowest_distance) { with_lowest_distance = station; lowest_distance = distance; } } return with_lowest_distance; }
/** Generates station list with which to populate the "All Stations" tab's Spinner. */ public void createAllStationsHash() { int len = stationLatLngMap.size(); allStationsList = new ArrayList<>(len); for (Station s : mBService.getStations()) { allStationsList.add(s.getName()); } Collections.sort(allStationsList); int count = 0; for (String station : allStationsList) { allStationsHash.put(count, station); fullHash.put(station, count); count++; } }
private void _renderStationIconBlock( FacesContext context, RenderingContext arc, UIXProcess process, Station station) throws IOException { process.setRowIndex(station.getRowIndex()); String baseStyleClass = station.getBaseStyleClass(); _renderIconBlock( context, arc, station.getIconNames(), station.getLabel(), baseStyleClass, baseStyleClass + _SUFFIX_ICON_CELL, station.getStates()); }
/** * Add station to line, if it's not already there. * * @param stn the station to add to this line */ public void addStation(Station stn) { if (!stations.contains(stn)) { stations.add(stn); // stn.addLine(this); } }
/** * Remove station from line * * @param stn the station to remove from this line */ public void removeStation(Station stn) { if (stations.contains(stn)) { stations.remove(stn); // stn.removeLine(this); } }
/** * ******************************************************************** * * @param the object that will remove an old association * @param the object that will be removed as the old association (neighbor) * ******************************************************************** */ public synchronized void deleteAssociation( Address address, Object neighbor, String AssociationID) { try { Address object = Database.get(Address.class, address.ID()); if (object != null) { int oldID = address.ID(); if (neighbor instanceof Station) { ((Station) neighbor).deleteAssociation(object, AssociationID); Transactions.AddCommand( new Command( getAccess(), CommandType.DELETE_ASSOCIATION, CommandTargetLayer.VIEW, oldID, address, object, Station.class, ((Station) neighbor).ID(), neighbor, null)); } object.checkModelRestrictions(); object.checkRestrictions(); Transactions.getSession().store(object); } else { Transactions.CancelTransaction( "Failed in DeleteAssociation", "the Address does not exists"); } } catch (Exception e) { Transactions.CancelTransaction( "Failed in DeleteAssociation", "Error ocurred while trying to delete the association of Address"); } }
/* 这里的element参数,其实就是我们二维数组中的每一个一维数组,其中保存的是 * 每一行的所有数据,通过column这个参数依次写入到表格中的各个字段上。 * column具体值是多少我们并不知道,因此需要我们来判断,并根据他里面的值 * 来决定我们要将哪个数据返回。同样,该方法是不能返回NULL的。必须先检查数有效性。 */ public String getColumnText(Object element, int columnIndex) { Station station = (Station) element; if (station == null) // 解决表中空数据出现的错误 return null; switch (columnIndex) { case 0: return station.getStation_name(); case 1: return String.valueOf(station.getStation_downnumber()); case 2: return String.valueOf(station.getStation_upnumber()); case 3: return station.getStation_graph(); } return null; }
private static String toSerializedString(ArrayList<Station> stations) { String serialized = ""; for (Station s : stations) { String[] parameters = new String[4]; parameters[PARAMETER_STATION_NUMBER] = s.getNumber() + ""; parameters[PARAMETER_STATION_NAME] = s.getName(); parameters[PARAMETER_STATION_URL] = s.getUrl(); parameters[PARAMETER_STATION_TEMPERATURE] = s.getTemperature() + ""; for (String parameter : parameters) serialized += parameter + SEPARATE_PARAMETERS_TAG; serialized += SEPARATE_STATIONS_TAG; } return serialized; }
// Clears the previous List of segments and creates a new list. public void set_NumSegments(int num) { _segments.clear(); for (int i = 0; i < num; i++) { _segments.add(new Segment(this)); _segments.add(new UnknownSegment(this)); } _segments.add(_endStation.get_platform(this)); }
private static ArrayList<Station> toArrayList(String s) { // Toast.makeText(this, "toArray", Toast.LENGTH_LONG).show(); ArrayList<Station> stations = new ArrayList<Station>(); String[] stationsSeparated = s.split(SEPARATE_STATIONS_TAG); for (String singleStation : stationsSeparated) { String[] parameters = singleStation.split(SEPARATE_PARAMETERS_TAG); Station station = new Station( Integer.parseInt(parameters[PARAMETER_STATION_NUMBER]), parameters[PARAMETER_STATION_NAME], parameters[PARAMETER_STATION_URL]); station.setTemperature(Double.parseDouble(parameters[PARAMETER_STATION_TEMPERATURE])); stations.add(station); } return stations; }