/** * Creates a new, empty SessionDescription. The session is set as follows: * * <p>v=0 * * <p>o=this.createOrigin ("user", InetAddress.getLocalHost().toString()); * * <p>s=- * * <p>t=0 0 * * @throws SdpException SdpException, - if there is a problem constructing the SessionDescription. * @return a new, empty SessionDescription. */ public SessionDescription createSessionDescription() throws SdpException { SessionDescriptionImpl sessionDescriptionImpl = new SessionDescriptionImpl(); ProtoVersionField ProtoVersionField = new ProtoVersionField(); ProtoVersionField.setVersion(0); sessionDescriptionImpl.setVersion(ProtoVersionField); OriginField originImpl = null; try { originImpl = (OriginField) this.createOrigin("user", InetAddress.getLocalHost().getHostAddress()); } catch (UnknownHostException e) { e.printStackTrace(); } sessionDescriptionImpl.setOrigin(originImpl); SessionNameField sessionNameImpl = new SessionNameField(); sessionNameImpl.setValue("-"); sessionDescriptionImpl.setSessionName(sessionNameImpl); TimeDescriptionImpl timeDescriptionImpl = new TimeDescriptionImpl(); TimeField timeImpl = new TimeField(); timeImpl.setZero(); timeDescriptionImpl.setTime(timeImpl); Vector times = new Vector(); times.addElement(timeDescriptionImpl); sessionDescriptionImpl.setTimeDescriptions(times); sessionDescriptionsList.addElement(sessionDescriptionImpl); return sessionDescriptionImpl; }
/** * Returns TimeDescription unbounded (i.e. "t=0 0"); * * @throws SdpException * @return TimeDescription unbounded (i.e. "t=0 0"); */ public TimeDescription createTimeDescription() throws SdpException { TimeDescriptionImpl timeDescriptionImpl = new TimeDescriptionImpl(); TimeField timeImpl = new TimeField(); timeImpl.setZero(); timeDescriptionImpl.setTime(timeImpl); return timeDescriptionImpl; }
/** * Returns TimeDescription object with the specified properties. * * @param start start time. * @param stop stop time. * @throws SdpException if the parameters are null * @return TimeDescription */ public TimeDescription createTimeDescription(Date start, Date stop) throws SdpException { TimeDescriptionImpl timeDescriptionImpl = new TimeDescriptionImpl(); TimeField timeImpl = new TimeField(); timeImpl.setStart(start); timeImpl.setStop(stop); timeDescriptionImpl.setTime(timeImpl); return timeDescriptionImpl; }
@SuppressWarnings("deprecation") private static Date getCombineDate(DateField dateField, TimeField timeField) { Date result = null; Date date = dateField.getValue(); Date time = timeField.getValue(); if (date != null && time != null) { result = new Date( date.getYear(), date.getMonth(), date.getDate(), time.getHours(), time.getMinutes(), time.getSeconds()); } return result; }
@Override protected boolean init(CommandSender sender, String[] args) { if (inputs.length != 1) { error(sender, "Expecting 1 clock input."); return false; } if (args.length > 0) { if (args[0].equalsIgnoreCase("earthtime")) earthtime = true; else if (args[0].equalsIgnoreCase("gametime")) earthtime = false; } if (args.length > 1) { try { timeField = TimeField.valueOf(args[1].toUpperCase()); } catch (IllegalArgumentException ie) { error(sender, "Unknown time field: " + args[1]); return false; } } else { timeField = TimeField.TICK; } if (!earthtime && (timeField == TimeField.SECOND1 || timeField == TimeField.SECOND10)) { error(sender, "second1 or second10 time fields are not allowed when using gametime."); return false; } if (args.length > 2) { w = redstoneChips.getServer().getWorld(args[2]); if (w == null) { error(sender, "Unknown world name: " + args[2]); return false; } } else { w = world; } maxval = (int) (Math.pow(2, outputs.length) - 1); return true; }
public ArchiveView(final ArchiveHandler archiveHandler, ListStore<Device> deviceStore) { this.archiveHandler = archiveHandler; deviceStore.addStoreHandlers(deviceStoreHandlers); this.deviceStore = deviceStore; DeviceProperties deviceProperties = GWT.create(DeviceProperties.class); deviceCombo = new ComboBox<Device>(deviceStore, deviceProperties.label()); // Element that displays the current track color styleButtonTrackColor = new TextButton(); styleButtonTrackColor .getElement() .getStyle() .setProperty("backgroundColor", "#".concat(style.DEFAULT_COLOR)); styleButtonTrackColor.getElement().getStyle().setCursor(Style.Cursor.TEXT); // Menu with the small palette smallColorMenu = new ExtColorMenu(ArchiveStyle.COLORS, ArchiveStyle.COLORS); smallColorMenu.setColor(ArchiveStyle.DEFAULT_COLOR); smallColorMenu .getPalette() .addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { style.setTrackColor(event.getValue()); smallColorMenu.hide(true); fullColorMenu.getPalette().setValue("", false); styleButtonTrackColor .getElement() .getStyle() .setProperty("backgroundColor", "#".concat(style.getTrackColor())); } }); // Menu with the complete palette fullColorMenu = new ColorMenu(); fullColorMenu .getPalette() .addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { style.setTrackColor(event.getValue()); fullColorMenu.hide(true); smallColorMenu.getPalette().setValue("", false); styleButtonTrackColor .getElement() .getStyle() .setProperty("backgroundColor", "#".concat(style.getTrackColor())); } }); // Markers routeMarkersType = new Menu(); for (Object[] obj : new Object[][] { {i18n.noMarkers(), null}, {i18n.standardMarkers(), PositionIconType.iconArchive}, {i18n.reducedMarkers(), PositionIconType.dotArchive} }) { CheckMenuItem item = new CheckMenuItem((String) obj[0]); final PositionIconType iconType = (PositionIconType) obj[1]; item.setGroup("markers"); item.setChecked( iconType == ApplicationContext.getInstance().getUserSettings().getArchiveMarkerType()); if (item.isChecked()) { style.setIconType(iconType); } item.addSelectionHandler( new SelectionHandler<Item>() { @Override public void onSelection(SelectionEvent<Item> event) { style.setIconType(iconType); archiveHandler.onChangeArchiveMarkerType(iconType); } }); routeMarkersType.add(item); } devicesTabs = new TabPanel(GWT.<TabPanel.TabPanelAppearance>create(BlueTabPanelBottomAppearance.class)); archivePanels = new HashMap<Long, ArchivePanel>(); uiBinder.createAndBindUi(this); markersMenu.setText(i18n.overlayType(UserSettings.OverlayType.MARKERS)); // Initialize with current time long min = 60 * 1000; Date now = new Date(); Date to = new Date(((now.getTime() + 15 * min) / (15 * min)) * 15 * min); Date from = new Date(to.getTime() - 60 * min); fromDate.setValue(from); fromTime.setValue(from); toDate.setValue(to); toTime.setValue(to); }
@Override public void inputChange(int inIdx, boolean state) { if (state) { int time; if (earthtime) { Calendar now = Calendar.getInstance(); if (timeField == TimeField.SECOND) time = now.get(Calendar.SECOND); else if (timeField == TimeField.SECONDOFDAY || timeField == TimeField.TICK) time = now.get(Calendar.SECOND) + now.get(Calendar.MINUTE) * 60 + now.get(Calendar.HOUR_OF_DAY) * 60; else if (timeField == TimeField.MINUTE) time = now.get(Calendar.MINUTE); else if (timeField == TimeField.MINUTEOFDAY) time = now.get(Calendar.MINUTE) + now.get(Calendar.HOUR_OF_DAY) * 60; else if (timeField == TimeField.HOUR) time = now.get(Calendar.HOUR_OF_DAY); else if (timeField == TimeField.HOUR1) { // hour of day, ones digit time = now.get(Calendar.HOUR_OF_DAY) % 10; } else if (timeField == TimeField.HOUR10) { // hour of day, tens digit time = now.get(Calendar.HOUR_OF_DAY) / 10; } else if (timeField == TimeField.MINUTE1) { // minute of hour, ones digit time = now.get(Calendar.MINUTE) % 10; } else if (timeField == TimeField.MINUTE10) { // minute of hour, tens digit time = now.get(Calendar.MINUTE) / 10; } else if (timeField == TimeField.SECOND1) { // second of minute, ones digit time = now.get(Calendar.SECOND) % 10; } else if (timeField == TimeField.SECOND10) { time = now.get(Calendar.SECOND) / 10; } else time = -1; } else { if (timeField == TimeField.SECONDOFDAY || timeField == TimeField.TICK || timeField == TimeField.SECOND) time = (int) w.getTime(); else if (timeField == TimeField.MINUTEOFDAY) time = (int) Math.round(w.getTime() / ticksPerMinute); else if (timeField == TimeField.MINUTE) time = (int) Math.round((w.getTime() % 1000) / ticksPerMinute); else if (timeField == TimeField.HOUR) time = (int) (w.getTime() / ticksPerHour); else if (timeField == TimeField.HOUR1) { // hour of day, ones digit time = ((int) (w.getTime() / ticksPerHour)) % 10; } else if (timeField == TimeField.HOUR10) { // hour of day, tens digit time = ((int) (w.getTime() / ticksPerHour)) / 10; } else if (timeField == TimeField.MINUTE1) { // minute of hour, ones digit time = ((int) Math.round((w.getTime() % 1000) / ticksPerMinute)) % 10; } else if (timeField == TimeField.MINUTE10) { // minute of hour, tens digit time = ((int) Math.round((w.getTime() % 1000) / ticksPerMinute)) / 10; } else time = -1; } time = Math.min(time, timeField.maxTime(earthtime)); if (hasDebuggers()) debug("Time is " + time); int output; int maxTime = timeField.maxTime(earthtime); if (maxTime > maxval) { float c = (float) (maxval + 1) / (float) (maxTime + 1); output = (int) (c * time); } else output = time; sendInt(0, outputs.length, output); } }
/** * Returns an unbounded Time specification (i.e., "t=0 0"). * * @throws SdpException * @return an unbounded Time specification (i.e., "t=0 0"). */ public Time createTime() throws SdpException { TimeField timeImpl = new TimeField(); timeImpl.setZero(); return timeImpl; }
/** * Returns a Time specification with the specified start and stop times. * * @param start start time * @param stop stop time * @throws SdpException if the parameters are null * @return a Time specification with the specified start and stop times. */ public Time createTime(Date start, Date stop) throws SdpException { TimeField timeImpl = new TimeField(); timeImpl.setStart(start); timeImpl.setStop(stop); return timeImpl; }