/** * Initializes fundamental diagram change event editing panel. * * @param ne Network Element. * @param em Event Manager. * @param etm Event Table model. */ public synchronized void initialize( AbstractNetworkElement ne, EventManager em, EventTableModel etm) { eventTable = etm; myEvent = new EventFD(); mf = ((AbstractLinkHWC) ne).getMaxFlow(); drp = Math.max(0, Math.min(mf, ((AbstractLinkHWC) ne).getCapacityDrop())); cd = ((AbstractLinkHWC) ne).getCriticalDensity(); jd = ((AbstractLinkHWC) ne).getJamDensity(); initialize(ne, em); }
private static XYDataset createForceDataset(int i) { TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); TimeSeries timeseries = new TimeSeries("Wind Force", org.jfree.data.time.Minute.class); Object obj = new Minute(); double d = 3D; for (int j = 0; j < i; j++) { timeseries.add(((RegularTimePeriod) (obj)), d); obj = ((RegularTimePeriod) (obj)).next(); d = Math.max(0.5D, d + (Math.random() - 0.5D) * 0.5D); } timeseriescollection.addSeries(timeseries); return timeseriescollection; }
public static void main(String[] args) { ChartWindow cw = new ChartWindow("test"); double[] c1 = new double[100]; for (int i = 0; i < c1.length; i++) { c1[i] = Math.random(); } cw.draw(c1); double[] c2 = new double[100]; for (int i = 0; i < c2.length; i++) { c2[i] = Math.random(); } cw.draw(c2); }
public void actionPerformed(ActionEvent actionevent) { if (actionevent.getActionCommand().equals("ADD_DATA")) { double d = 0.90000000000000002D + 0.20000000000000001D * Math.random(); lastValue = lastValue * d; Millisecond millisecond = new Millisecond(); System.out.println("Now = " + millisecond.toString()); series.add(new Millisecond(), lastValue); } }
public void actionPerformed(ActionEvent actionevent) { for (int i = 0; i < 3; i++) if (actionevent.getActionCommand().endsWith(String.valueOf(i))) { Millisecond millisecond1 = new Millisecond(); System.out.println("Now = " + millisecond1.toString()); lastValue[i] = lastValue[i] * (0.90000000000000002D + 0.20000000000000001D * Math.random()); datasets[i].getSeries(0).add(new Millisecond(), lastValue[i]); } if (actionevent.getActionCommand().equals("ADD_ALL")) { Millisecond millisecond = new Millisecond(); System.out.println("Now = " + millisecond.toString()); for (int j = 0; j < 3; j++) { lastValue[j] = lastValue[j] * (0.90000000000000002D + 0.20000000000000001D * Math.random()); datasets[j].getSeries(0).add(new Millisecond(), lastValue[j]); } } }
public YIntervalSeries getYIntervalSeries(String rowname, long factor) { YIntervalSeries mydataset = new YIntervalSeries(rowname); double sdcount = 0; double total = 0; Vector<Double> totalvalues = new Vector<Double>(); double avgtotal = 0; double minus = 0; double plus = 0; double zero = 0; for (Integer key : ysum.keySet()) { Double value = ysum.get(key) / (double) count.get(key); Double point = (double) xsum.get(key) / (double) count.get(key); Vector<Double> listofvalues = values.get(key); double sumofdiff = 0.0; for (Double onevalue : listofvalues) { sumofdiff += Math.pow(onevalue - value, 2); sdcount++; total += Math.pow(onevalue, 2); avgtotal += onevalue; totalvalues.add(onevalue); if (onevalue == 1) { plus++; } ; if (onevalue == -1) { minus++; } ; if (onevalue == 0) { zero++; } ; } double sd = Math.sqrt(sumofdiff / count.get(key)); // mydataset.add(point/factor, value,value+sd,value-sd); // mydataset.add(point/factor, value,value,value); mydataset.add( point / factor, value, value + 1.96 * (sd / Math.sqrt(count.get(key))), value - 1.96 * (sd / Math.sqrt(count.get(key)))); } double sdtotal = 0; double avgsd = total / sdcount; double test = 0; for (Double onevalue : totalvalues) { sdtotal += Math.pow(Math.pow(onevalue, 2) - (total / sdcount), 2); test += onevalue; } // System.out.println(rowname+" mean square: "+avgsd+" // +/-95%:"+1.96*Math.sqrt(sdtotal/sdcount)/Math.sqrt(sdcount)); // System.out.println("total -1:"+minus+" total +1:"+plus+" zero: "+zero // +" total:"+sdcount); return mydataset; }
private static XYDataset createDirectionDataset(int i) { TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); TimeSeries timeseries = new TimeSeries("Wind Direction", org.jfree.data.time.Minute.class); Object obj = new Minute(); double d = 180D; for (int j = 0; j < i; j++) { timeseries.add(((RegularTimePeriod) (obj)), d); obj = ((RegularTimePeriod) (obj)).next(); d += (Math.random() - 0.5D) * 15D; if (d < 0.0D) { d += 360D; continue; } if (d > 360D) d -= 360D; } timeseriescollection.addSeries(timeseries); return timeseriescollection; }
/** Fills the panel with event specific fields. */ protected void fillPanel() { JLabel l; Box fdp = Box.createVerticalBox(); fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram")); fdChart = makeFDChart(); ChartPanel cp = new ChartPanel(fdChart); cp.setMinimumDrawWidth(100); cp.setMinimumDrawHeight(60); cp.setPreferredSize(new Dimension(250, 80)); fdp.add(new JScrollPane(cp)); JPanel prmp = new JPanel(new SpringLayout()); l = new JLabel("Capacity:", JLabel.TRAILING); prmp.add(l); spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0)); spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00")); spinMaxFlow.addChangeListener(this); spinMaxFlow.setName(nmSpinMaxFlow); l.setLabelFor(spinMaxFlow); prmp.add(spinMaxFlow); l = new JLabel("Cap.Drop:", JLabel.TRAILING); prmp.add(l); spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0)); spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00")); spinCapDrop.addChangeListener(this); spinCapDrop.setName(nmSpinCapDrop); l.setLabelFor(spinCapDrop); prmp.add(spinCapDrop); l = new JLabel("C.Density:", JLabel.TRAILING); prmp.add(l); spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0)); spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00")); spinCritDen.addChangeListener(this); spinCritDen.setName(nmSpinCritDen); l.setLabelFor(spinCritDen); prmp.add(spinCritDen); l = new JLabel(" V:", JLabel.TRAILING); prmp.add(l); spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0)); spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00")); spinVff.addChangeListener(this); spinVff.setName(nmSpinVff); l.setLabelFor(spinVff); prmp.add(spinVff); l = new JLabel("J.Density:", JLabel.TRAILING); prmp.add(l); spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0)); spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00")); spinJamDen.addChangeListener(this); spinJamDen.setName(nmSpinJamDen); l.setLabelFor(spinJamDen); prmp.add(spinJamDen); l = new JLabel(" W:", JLabel.TRAILING); prmp.add(l); if (jd == cd) jd = cd + 1; int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999); spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0)); spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00")); spinWc.addChangeListener(this); spinWc.setName(nmSpinWc); l.setLabelFor(spinWc); prmp.add(spinWc); SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2); fdp.add(prmp); // add(new JScrollPane(fdp)); add(fdp); return; }