コード例 #1
0
ファイル: LJ3MDApp.java プロジェクト: eskilj/mvp
  //    int frame = 0;
  public void paint(Graphics g) {
    // System.out.println("frame: " + (frame++));
    lStatus.setText(
        "t = "
            + df.format(md.dt * md.step)
            + ", "
            + "N = "
            + md.N
            + ", "
            + "E/N = "
            + df.format(md.E / md.N)
            + ", "
            + "U/N = "
            + df.format(md.U / md.N)
            + ", "
            + "K/N = "
            + df.format(md.K / md.N)
            + ", "
            + "p = "
            + df.format(md.p)
            + ";");
    tAvK.setText(df.format(md.avK.getAve() / md.N) + "  ");
    tAvU.setText(df.format(md.avU.getAve() / md.N) + "  ");
    tTemp.setText(df.format((2 * md.K) / (3 * (md.N - 1))) + "  ");
    tAvp.setText(df.format(md.avp.getAve()) + "  ");
    canvas.refresh(md.getXWrap(), md.N, true, false);
    cpnl.repaint();
    spnl.repaint();

    try {

      PrintWriter wavefunc =
          new PrintWriter(new FileOutputStream(new File("energyData.txt"), true));
      wavefunc.print(md.E / md.N + " " + md.K / md.N + " " + md.U / md.N);
      wavefunc.println();
      wavefunc.close();
    } catch (IOException ex) {
    }

    try {

      PrintWriter tempwriter =
          new PrintWriter(new FileOutputStream(new File("tempData.txt"), true));
      tempwriter.print(df.format((2 * md.K) / (3 * (md.N - 1))));
      tempwriter.println();
      tempwriter.close();
    } catch (IOException ex) {
    }
  }
コード例 #2
0
ファイル: LJ3MDApp.java プロジェクト: eskilj/mvp
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (model != null) {
     newImgBuf(); // refresh the image buffer if necessary
     // compute the real-to-screen ratio, this variable differs
     // from model.real2Screen by zoomScale
     Dimension sz = getSize();
     double real2Screen0 = model.getScaleFromSpan(realSpan, sz.width, sz.height);
     model.setMatrix(viewMatrix, real2Screen0 * zoomScale, sz.width / 2, sz.height / 2);
     imgG.setColor(Color.BLACK);
     imgG.fillRect(0, 0, sz.width, sz.height);
     model.paint(imgG);
     g.drawImage(img, 0, 0, this);
   }
 }
コード例 #3
0
ファイル: EditFrame.java プロジェクト: BrotherPhil/ROPE
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
コード例 #4
0
ファイル: LJ3MDApp.java プロジェクト: eskilj/mvp
  public LJ3MDApp() {
    tNum.setHorizontalAlignment(JTextField.CENTER);
    tTemp.setHorizontalAlignment(JTextField.CENTER);
    tRho.setHorizontalAlignment(JTextField.CENTER);
    tSpeed.setHorizontalAlignment(JTextField.CENTER);

    tAvK.setHorizontalAlignment(JTextField.RIGHT);
    tAvU.setHorizontalAlignment(JTextField.RIGHT);
    tAvp.setHorizontalAlignment(JTextField.RIGHT);

    float[] aveKing = new float[501];
    float[] avePot = new float[501];
    float[] aveEn = new float[501];

    JFrame box = new JFrame();
    box.setLayout(new BorderLayout());
    box.setSize(1000, 1000);
    box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    cpnl = new JPanel(); // create a panel for controls
    cpnl.setLayout(new GridLayout(18, 2));
    box.add(cpnl, BorderLayout.EAST);

    // add controls
    cpnl.add(bStart);
    bStart.addActionListener(this);

    cpnl.add(bReset);
    bReset.addActionListener(this);

    cpnl.add(new JLabel(" N:"));
    tNum.addActionListener(this);
    cpnl.add(tNum);

    cpnl.add(new JLabel(" Density (\u03c1):"));
    tRho.addActionListener(this);
    cpnl.add(tRho);

    cpnl.add(new JLabel(" Steps/frame:"));
    tSpeed.addActionListener(this);
    cpnl.add(tSpeed);

    cpnl.add(bTstat);
    bTstat.addActionListener(this);

    cpnl.add(bPot);
    bPot.addActionListener(this);

    cpnl.add(new JLabel(" < K/N > :"));
    tAvK.setEditable(false);
    cpnl.add(tAvK);

    cpnl.add(new JLabel(" Temperature:"));
    tTemp.setEditable(false);
    cpnl.add(tTemp);

    cpnl.add(new JLabel(" < U/N > :"));
    tAvU.setEditable(false);
    cpnl.add(tAvU);

    cpnl.add(new JLabel(" < pressure > :"));
    tAvp.setEditable(false);
    cpnl.add(tAvp);

    cpnl.add(bRetime);
    bRetime.addActionListener(this);

    spnl = new JPanel(); // create a panel for status
    box.add(spnl, BorderLayout.SOUTH);
    lStatus.setFont(new Font("Courier", 0, 12));
    spnl.add(lStatus);

    canvas = new XYZCanvas();
    box.add(canvas, BorderLayout.CENTER);

    timer = new Timer(delay, this);
    timer.start();
    //        timer.stop();
    box.setVisible(true);
  }
コード例 #5
0
  @Analyzer(
      name = "Event Data Attribute Visualizer",
      names = {"Log"})
  public JComponent analyze(LogReader log) {
    /*
     * this plugin takes a log, shows a list of available data-attributes
     * and a list of cases After selecting a data-attribute (and possibly a
     * case) a graph is made of the value of the data-attribute against
     * either time or against the sequence of events.
     *
     * input: log with data attributes gui-input: select a data-attribute,
     * choose time or event-sequence, and possibly a case
     *
     * internally : if not caseselected -> scatterplot of values against
     * time/event-number else show graph for value against time/event-number
     *
     * createGraph : check number / string
     */
    mylog = log;
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    chartPanel = new JPanel();
    chartPanel.setLayout(new BoxLayout(chartPanel, BoxLayout.PAGE_AXIS));

    optionsPanel = new JPanel();
    optionsPanel.setLayout(new SpringLayout());

    JLabel attributelabel = new JLabel("Select attributes to use");
    attributeslist = new JList(getAttributes());
    attributeslist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    attributeslist.setLayoutOrientation(JList.VERTICAL);
    optionsPanel.add(attributelabel);
    optionsPanel.add(attributeslist);

    JLabel xlabel = new JLabel("Chart type");
    String[] xvalues = new String[4];
    xvalues[0] = " Attribute values against event sequence";
    xvalues[1] = "Attribute values against timestamps";
    xvalues[2] = "Average attribute values against event sequence";
    xvalues[3] = "Average attribute values against timestamps";
    xbox = new JComboBox(xvalues);
    xbox.setMaximumSize(xbox.preferredSize());
    xbox.setSelectedIndex(1);

    xbox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            if (cb.getSelectedIndex() == 3) {
              BSpinner.setVisible(true);
            } else {
              BSpinner.setVisible(false);
            }
          };
        });

    optionsPanel.add(xlabel);
    optionsPanel.add(xbox);

    JLabel timelabel = new JLabel("show time by ");
    String[] timevalues = new String[4];
    timevalues[0] = "second";
    timevalues[1] = "minute";
    timevalues[2] = "hour";
    timevalues[3] = "day";
    timebox = new JComboBox(timevalues);
    timebox.setMaximumSize(timebox.preferredSize());
    timebox.setSelectedIndex(1);
    optionsPanel.add(timelabel);
    optionsPanel.add(timebox);

    SpinnerModel Bmodel = new SpinnerNumberModel(10, 2, 1000000, 1);
    BSpinner = new JSpinner(Bmodel);
    JLabel BLabel = new JLabel("Select histogram barsize");
    JLabel B2Label = new JLabel("used for average against timestamps");
    BSpinner.setMaximumSize(BSpinner.preferredSize());
    BSpinner.setVisible(false);
    optionsPanel.add(BLabel);
    optionsPanel.add(B2Label);
    optionsPanel.add(BSpinner);

    JButton updatebutton = new JButton("update");
    updatebutton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            Object[] sels = attributeslist.getSelectedValues();
            String[] els = new String[sels.length];
            for (int i = 0; i < sels.length; i++) {
              els[i] = sels[i].toString();
            }

            long timesize = 1000;
            switch (timebox.getSelectedIndex()) {
              case 0:
                timesize = 1000;
                break;
              case 1:
                timesize = 1000 * 60;
                break;
              case 2:
                timesize = 1000 * 60 * 60;
                break;
              case 3:
                timesize = 1000 * 60 * 60 * 24;
                break;
            }

            String xname = null;
            JFreeChart mychart = null;
            if (xbox.getSelectedIndex() == 0) {
              data = getDataAttributes(els, false, timesize);
              xname = "Event sequence";
              mychart =
                  ChartFactory.createScatterPlot(
                      "Scatterplot of all values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
            } else if (xbox.getSelectedIndex() == 1) {
              data = getDataAttributes(els, true, timesize);
              xname = "Time(" + timebox.getSelectedItem() + ") since beginning of the process";
              mychart =
                  ChartFactory.createScatterPlot(
                      "Scatterplot of all values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
            } else if (xbox.getSelectedIndex() == 2) {
              xname = "Event sequence";
              data = getHistrogrammedDataAttributes(els, 1, 1);
              mychart =
                  ChartFactory.createXYLineChart(
                      "Average values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
              mychart.setBackgroundPaint(Color.white);
              XYPlot plot = mychart.getXYPlot();

              plot.setBackgroundPaint(Color.white);
              plot.setDomainGridlinePaint(Color.white);
              plot.setRangeGridlinePaint(Color.white);

              DeviationRenderer renderer = new DeviationRenderer(true, true);
              renderer.setSeriesStroke(
                  0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
              renderer.setSeriesStroke(0, new BasicStroke(2.0f));
              renderer.setSeriesStroke(1, new BasicStroke(2.0f));
              renderer.setSeriesStroke(2, new BasicStroke(2.0f));
              renderer.setSeriesStroke(3, new BasicStroke(2.0f));
              renderer.setSeriesFillPaint(0, Color.red);
              renderer.setSeriesFillPaint(1, Color.blue);
              renderer.setSeriesFillPaint(2, Color.green);
              renderer.setSeriesFillPaint(3, Color.orange);
              plot.setRenderer(renderer);
              // change the auto tick unit selection to integer units
              // only...
              NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
              // yAxis.setAutoRangeIncludesZero(false);
              yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

              NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
              xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            } else {
              xname = "Time(" + timebox.getSelectedItem() + "s) since beginning of the process";
              data =
                  getHistrogrammedDataAttributes(
                      els, ((Integer) BSpinner.getValue()) * timesize, timesize);
              mychart =
                  ChartFactory.createXYLineChart(
                      "Average values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
              mychart.setBackgroundPaint(Color.white);
              XYPlot plot = mychart.getXYPlot();

              plot.setBackgroundPaint(Color.white);
              plot.setDomainGridlinePaint(Color.white);
              plot.setRangeGridlinePaint(Color.white);

              DeviationRenderer renderer = new DeviationRenderer(true, true);
              renderer.setSeriesStroke(
                  0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
              renderer.setSeriesStroke(0, new BasicStroke(2.0f));
              renderer.setSeriesStroke(1, new BasicStroke(2.0f));
              renderer.setSeriesStroke(2, new BasicStroke(2.0f));
              renderer.setSeriesStroke(3, new BasicStroke(2.0f));
              renderer.setSeriesFillPaint(0, Color.red);
              renderer.setSeriesFillPaint(1, Color.blue);
              renderer.setSeriesFillPaint(2, Color.green);
              renderer.setSeriesFillPaint(3, Color.orange);
              plot.setRenderer(renderer);
              // change the auto tick unit selection to integer units
              // only...
              NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
              // yAxis.setAutoRangeIncludesZero(false);
              yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            }

            ChartPanel mychartpanel = new ChartPanel(mychart);
            mychartpanel.setBackground(Color.white);
            chartPanel.removeAll();
            chartPanel.add(mychartpanel);
            chartPanel.updateUI();
          };
        });
    optionsPanel.add(updatebutton);

    JSplitPane splitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, optionsPanel, chartPanel);

    SpringUtils.makeCompactGrid(
        optionsPanel,
        10,
        1, // rows, cols
        6,
        2, // initX, initY
        6,
        2); // xPad, yPad

    mainPanel.add(splitPanel, BorderLayout.CENTER);
    return mainPanel;
  }