/** Property keys converted to all uppercase. */ private boolean parseProperty(String line, Properties properties) { final int index = line.indexOf(':'); if (index < 0) return false; final String key = line.substring(0, index).trim(); final String value = line.substring(index + 1).trim(); properties.setProperty(key.toUpperCase(), value); return true; }
protected void closingDown(TerminalViewInterface view) { Sessions sess = manager.getSessions(); if (log.isDebugEnabled()) { log.debug("number of active sessions is " + sess.getCount()); } if (viewNamesForNextStartBuilder == null) { // preserve sessions for next boot viewNamesForNextStartBuilder = new StringBuilder(); } while (view.getSessionViewCount() > 0) { SessionPanel sesspanel = view.getSessionAt(0); viewNamesForNextStartBuilder.append("-s ").append(sesspanel.getSessionName()).append(" "); closeSessionInternal(sesspanel); } sessions.setProperty( "emul.frame" + view.getFrameSequence(), view.getX() + "," + view.getY() + "," + view.getWidth() + "," + view.getHeight()); frames.remove(view); view.dispose(); log.debug("number of active sessions we have after shutting down " + sess.getCount()); log.info("view settings " + viewNamesForNextStartBuilder); if (sess.getCount() == 0) { sessions.setProperty("emul.width", Integer.toString(view.getWidth())); sessions.setProperty("emul.height", Integer.toString(view.getHeight())); sessions.setProperty("emul.view", viewNamesForNextStartBuilder.toString()); // save off the session settings before closing down ConfigureFactory.getInstance() .saveSettings( ConfigureFactory.SESSIONS, ConfigureFactory.SESSIONS, "------ Defaults --------"); if (controller != null) { controller.interrupt(); } System.exit(0); } }
@Override public void applyInput(Properties props, boolean selected) throws UserInputException { Component tab = null; try { tab = this.tabModel; String os = "3.1_64x32"; if (this.btnMon31_64x16.isSelected()) { os = "3.1_64x16"; } else if (this.btnMonSCCH80.isSelected()) { os = "SCCH8.0"; } else if (this.btnMonSCCH1088.isSelected()) { os = "SCCH10/88"; } else if (this.btnMon2010.isSelected()) { os = "2010"; } props.setProperty(this.propPrefix + "os.version", os); tab = this.tabRF; this.tabRF.applyInput(props, selected); tab = this.tabGIDE; this.tabGIDE.applyInput(props, selected); tab = this.tabSCCH; this.tabSCCH.applyInput(props, selected); tab = this.tab2010; this.fldAltPio2Rom2010.applyInput(props, selected); this.fldRomBank2010.applyInput(props, selected); tab = this.tabExt; EmuUtil.setProperty(props, this.propPrefix + "color", this.btnColor.isSelected()); EmuUtil.setProperty( props, this.propPrefix + "floppydisk.enabled", this.btnFloppyDisk.isSelected()); EmuUtil.setProperty(props, this.propPrefix + "kcnet.enabled", this.btnKCNet.isSelected()); EmuUtil.setProperty(props, this.propPrefix + "vdip.enabled", this.btnVDIP.isSelected()); EmuUtil.setProperty( props, this.propPrefix + "joystick.enabled", this.btnJoystick.isSelected()); tab = this.tabEtc; EmuUtil.setProperty(props, this.propPrefix + "paste.fast", this.btnPasteFast.isSelected()); this.fldAltOS.applyInput(props, selected); this.fldAltFont.applyInput(props, selected); } catch (UserInputException ex) { if (tab != null) { this.tabbedPane.setSelectedComponent(tab); } throw ex; } }
private void speichern(Path saveName) { Properties prop = new Properties(); if (!quellListModel.isEmpty()) for (int i = 0; i < quellListModel.getSize(); i++) prop.setProperty( String.format("quellMenu%d", i), quellListModel.getElementAt(i).getValueMember().toString()); if (!zielListModel.isEmpty()) for (int i = 0; i < zielListModel.getSize(); i++) prop.setProperty( String.format("zielMenu%d", i), zielListModel.getElementAt(i).getValueMember().toString()); try { FileOutputStream out = new FileOutputStream(saveName.toString()); prop.store(out, null); out.close(); } catch (Exception e) { e.printStackTrace(); } }
/** * Add the given file name to the list of recent files in the given Properties object, trimming * the length of the list to 10. If the given name is already in the list, move it to the top. */ public static void addRecentFile(Properties preferences, String newName) { // - if newName isn't already in the list, we add it to the top of the list. // - if it's already in the list, we move it to the top. ArrayList<String> list = MiscUtilities.parseRecentFiles(preferences); if (list.contains(newName)) { // move it to the top : list.remove(newName); list.add(0, newName); } else { list.add(0, newName); } // store to preferences : for (int i = 0; i < MAX_RECENT_FILES && i < list.size(); i++) { String key = KEY_RECENT_FILE + "." + Integer.toString(i + 1); // starts from 1 String val = list.get(i); preferences.setProperty(key, val); } }
public Properties internalToProperties() { Properties props = new Properties(); StringBuffer st = new StringBuffer(); st.append(" "); for (int i = 0; i < visibleViewIds.size(); i++) { st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]); } // System.out.println(" visibleViewIds: " + st.toString()); props.setProperty("ndedit.visibleViewIds", st.toString()); props.setProperty("ndedit.cutPanelSizeW", (new Integer(cutPanelSize.width).toString())); props.setProperty("ndedit.cutPanelSizeH", (new Integer(cutPanelSize.height).toString())); props.setProperty("ndedit.cutPanelWMin", (new Integer(cutPanelMinSize.width).toString())); props.setProperty("ndedit.cutPanelHMin", (new Integer(cutPanelMinSize.height).toString())); props.setProperty("ndedit.cutPanelWMax", (new Integer(cutPanelMaxSize.width).toString())); props.setProperty("ndedit.cutPanelHMax", (new Integer(cutPanelMaxSize.height).toString())); props.setProperty("ndedit.lonReference", (new Double(lonReference).toString())); props.setProperty("ndedit.geoDisplayFormat", (new Integer(geoDisplayFormat).toString())); props.setProperty("ndedit.timeDisplayFormat", (new Integer(timeDisplayFormat).toString())); props.setProperty("ndedit.timeAxisMode", (new Integer(timeAxisMode).toString())); props.setProperty("ndedit.timeAxisReference", (new Double(timeAxisReference).toString())); String dpa = new Boolean(displayPanelAxes).toString(); props.setProperty("ndedit.displayPanelAxes", dpa); dpa = new Boolean(independentHandles).toString(); props.setProperty("ndedit.independentHandles", dpa); return props; }
private void addData( JFreeChart chart, DSLAMSource source, Timeinterval time, Serializable filter, Properties properties, Map<String, Object> colorScheme, Properties outputProperties) throws IOException { if (chart != null) { PerformanceCounterDataCollection cData = null; long dataSize = 0; try { cData = getPerformanceCounterDataCollection(source, time, filter, properties, outputProperties); Collection<PerformanceCounterData> data = null; Date d0 = null; // first timestamp for data Date d1 = null; // last timestamp for data RegularTimePeriod time0 = null; if (cData != null) { data = cData.getData(); { int l = data.size(); outputProperties.setProperty("data.count", Integer.toString(l)); } if (data != null && data.size() > 0) { dataSize = data.size(); // Set 'd0': { // TODO: Avoid assumption "data is sorted"! PerformanceCounterData e = data.iterator().next(); d0 = e.getTimestamp(); } // Set 'd1': { // TODO: Avoid assumption "data is sorted"! for (PerformanceCounterData e : data) { d1 = e.getTimestamp(); } } time0 = createRegularTimePeriod(d0); } } XYPlot plot = chart.getXYPlot(); // Set the first dataset: { TimeSeriesCollection dataset = new TimeSeriesCollection(); List<Paint> seriesPaint = new ArrayList<Paint>(); List<Stroke> seriesStroke = new ArrayList<Stroke>(); // Add series 'ES': { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("ES", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); // Add point: { int value = getES(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.es")); seriesStroke.add(STROKE_COUNTER_ES); dataset.addSeries(series); } } // Add series 'SES': { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("SES", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); // Add point: { int value = getSES(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.ses")); seriesStroke.add(STROKE_COUNTER_SES); dataset.addSeries(series); } } // Add series 'US': { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("US", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); // Add point: { int value = getUS(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.us")); seriesStroke.add(STROKE_COUNTER_US); dataset.addSeries(series); } } // superspeed { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("LEFTRS", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); { int value = getPreviousLEFTRS(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.previousleftrs")); seriesStroke.add(STROKE_COUNTER_US); dataset.addSeries(series); } } // ends { if (data != null && data.size() > 0) { boolean showLinearCurve = getShowLinearCurve(); if (showLinearCurve) { // Add series for a linear curve: { TimeSeries series = new TimeSeries("Linear", time0.getClass()); long t0 = d0.getTime(); long t1 = d1.getTime(); if (t0 < t1) { long timeX = 15 * 60 * 1000; // 15 minutes intervals // TODO: Read length of intervals from obtained data! double value0 = 0; double value1 = 900; // TODO: Read '900' from obtained data! long timeDelta = t1 - t0; double valueDelta = value1 - value0; long t = t0; int i = 0; while (t <= t1) { Date d = new Date(t); RegularTimePeriod timePeriod = createRegularTimePeriod(d); double value = value0 + ((t - t0) * valueDelta) / timeDelta; // Add point: { addOrUpdate(series, timePeriod, (double) value); } t += timeX; i += 1; } } seriesPaint.add(Color.red); seriesStroke.add(STROKE_COUNTER_DEFAULT); dataset.addSeries(series); } } } } setDefaultRenderer(chart, colorScheme, 0, seriesPaint, seriesStroke); plot.setDataset(0, dataset); plot.mapDatasetToRangeAxis(0, 0); } } finally { if (cData != null) { cData.dispose(); cData = null; } } if (outputProperties != null) { outputProperties.setProperty("data.count", Long.toString(dataSize)); } } }
protected JFreeChart createChart( DSLAMSource source, String LID, Timeinterval time, Properties properties, GraphRenderingInput input, Map<String, Object> colorScheme, Properties outputProperties) throws IOException { JFreeChart res = null; { JFreeChart chart = null; Timeinterval domainAxisTime = null; // Set 'chart': { String domainAxisTitle = null; // Set 'domainAxisTime': { DateFormat format = (DateFormat) colorScheme.get("date.format"); domainAxisTitle = "Time (" + time.toString(format) + ")"; } chart = ChartFactory.createTimeSeriesChart( null, // chart-title domainAxisTitle, // domain-axis label null, // value-axis label null, // dataset true, // legends required true, // generate tooltips false // generate URLs ); } XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); // Fix the domain axis: { fixDateAxisToTimeinterval(plot, time); domainAxisTime = time; } // Set the y-axis: { String axisTitle = "Count (/900s)"; ValueAxis a = new LogarithmicAxis(axisTitle); a.setLowerBound(0); a.setUpperBound(1000); // TODO: '1000' is '900' rounded up to nearest power of 10! // TODO: Get unit from data-model! // TODO: Get upper bound from data-model! plot.setRangeAxis(a); } String title = getTitle(); setDefaults(chart, colorScheme); setTitle(chart, LID, colorScheme, title, source, time); String filter = ""; // an empty string implies the default filter! // Set 'filter': { if (input != null) { Properties p = input.getProperties(); if (p != null) { String v = p.getProperty("data.filter"); if (v != null) { filter = v; } } } } addData(chart, source, time, filter, properties, colorScheme, outputProperties); if (outputProperties != null) { if (domainAxisTime != null) { outputProperties.setProperty("axis.domain.time", time.toString()); } } res = chart; } return res; }