Example #1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
Example #2
0
 public void setDemo(String demo) {
   setTitle("Jogl Demo: " + demo);
   if (animator == null) {
     animator = new Animator();
     animator.setIgnoreExceptions(true);
   }
   // stop();
   if (drawable != null) {
     gradientPanel.remove(drawable);
     animator.remove(drawable);
     drawable = null;
   }
   if (demo.equals("gears")) {
     drawable = new JGears();
     type = GEARS;
   }
   // else if(demo.equals("graphics")){
   //    type=GRAPHICS;
   //   drawable=new JGLGraphics();
   // }
   if (drawable != null) {
     gradientPanel.add(drawable, BorderLayout.CENTER);
     animator.add(drawable);
   }
 }
 // 定义添加一行格式化文本框的方法
 private void addRow(String labelText, final JFormattedTextField field) {
   mainPanel.add(new JLabel(labelText));
   mainPanel.add(field);
   final JLabel valueLabel = new JLabel();
   mainPanel.add(valueLabel);
   // 为"确定"按钮添加事件监听器
   // 当用户单击“确定”按钮时,文本框后显示文本框内的值
   okButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           Object value = field.getValue();
           // 如果该值是数组,使用Arrays的toString方法输出数组
           if (value.getClass().isArray()) {
             StringBuilder builder = new StringBuilder();
             builder.append('{');
             for (int i = 0; i < Array.getLength(value); i++) {
               if (i > 0) builder.append(',');
               builder.append(Array.get(value, i).toString());
             }
             builder.append('}');
             valueLabel.setText(builder.toString());
           } else {
             // 输出格式化文本框的值
             valueLabel.setText(value.toString());
           }
         }
       });
 }
  /**
   * Constructor for the RingFoilPosController object
   *
   * @param updatingController_in The Parameter
   */
  public RingFoilPosController(UpdatingEventController updatingController_in) {

    updatingController = updatingController_in;

    ringFoilPosCorr = new RingFoilPosCorrector("HORIZONTAL Ring Beam Position at Foil");
    ringFoilPosCorr.setMessageText(getMessageText());

    ringFoilPosMainPanel.setLayout(new BorderLayout());
    ringFoilPosMainPanel.add(ringFoilPosCorr.getPanel(), BorderLayout.CENTER);
  }
  /** @return */
  private JPanel createPreviewPane() {
    final JPanel panTable = new JPanel(new GridLayout(1, 1, 0, 0));

    this.outText = new JEditorPane("text/html", getEmptyHtmlPage());
    this.outText.setEditable(false);

    panTable.add(new JScrollPane(this.outText));

    return panTable;
  }
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the remove button
   if (e.getSource() == remove_button) {
     int row = table.getSelectedRow();
     model.removeRow(row);
     table.clearSelection();
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the remove all button
   if (e.getSource() == remove_all_button) {
     model.clearAll();
     table.setRowSelectionInterval(0, 0);
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the filter button
   if (e.getSource() == filter_button) {
     filter.showDialog();
     if (filter.okPressed()) {
       // Update the display with new filter
       model.setFilter(filter);
       table.repaint();
     }
   }
   // Check if the user pressed the start button
   if (e.getSource() == start_button) {
     start();
   }
   // Check if the user pressed the stop button
   if (e.getSource() == stop_button) {
     stop();
   }
   // Check if the user wants to switch layout
   if (e.getSource() == layout_button) {
     details_panel.remove(details_soap);
     details_soap.removeAll();
     if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
       details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
     } else {
       details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     }
     details_soap.setTopComponent(request_panel);
     details_soap.setRightComponent(response_panel);
     details_soap.setResizeWeight(.5);
     details_panel.add(details_soap, BorderLayout.CENTER);
     details_panel.validate();
     details_panel.repaint();
   }
   // Check if the user is changing the reflow option
   if (e.getSource() == reflow_xml) {
     request_text.setReflowXML(reflow_xml.isSelected());
     response_text.setReflowXML(reflow_xml.isSelected());
   }
 }
Example #7
0
 public void propertyChange(PropertyChangeEvent evt) {
   if (DisplayOptions.isUpdateUIEvent(evt)) {
     SwingUtilities.updateComponentTreeUI(this);
     gradientPanel.remove(drawable);
     JPanel newpanel = createGradientPanel();
     contentPane.remove(gradientPanel);
     gradientPanel = newpanel;
     gradientPanel.add(drawable, BorderLayout.CENTER);
     contentPane.add(gradientPanel, BorderLayout.CENTER);
   }
 }
  /** Initializes this dialog. */
  private void initDialog() {
    setMinimumSize(new Dimension(640, 480));

    final JComponent settingsPane = createSettingsPane();
    final JComponent previewPane = createPreviewPane();

    final JPanel contentPane = new JPanel(new GridBagLayout());
    contentPane.add(
        settingsPane,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.NONE,
            new Insets(2, 0, 2, 0),
            0,
            0));
    contentPane.add(
        previewPane,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.BOTH,
            new Insets(2, 0, 2, 0),
            0,
            0));

    final JButton runAnalysisButton = ToolUtils.createRunAnalysisButton(this);
    this.runAnalysisAction = (RestorableAction) runAnalysisButton.getAction();

    final JButton exportButton = ToolUtils.createExportButton(this);
    this.exportAction = exportButton.getAction();
    this.exportAction.setEnabled(false);

    final JButton closeButton = ToolUtils.createCloseButton();
    this.closeAction = closeButton.getAction();

    final JComponent buttons =
        SwingComponentUtils.createButtonPane(runAnalysisButton, exportButton, closeButton);

    SwingComponentUtils.setupWindowContentPane(this, contentPane, buttons, runAnalysisButton);
  }
Example #9
0
  public GLDemo() {
    super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false);

    DisplayOptions.addChangeListener(this);

    contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    gradientPanel = createGradientPanel();

    contentPane.add(gradientPanel, BorderLayout.CENTER);

    checkBox = new JCheckBox("Transparent", true);
    checkBox.setActionCommand("transparancy");
    checkBox.addActionListener(this);
    optionsPan = new JPanel();
    optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false));
    optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED));

    optionsPan.add(checkBox);

    runButton = new JToggleButton("Run");
    runButton.setActionCommand("run");
    runButton.setSelected(false);
    runButton.addActionListener(this);

    optionsPan.add(runButton);

    getContentPane().add(optionsPan, BorderLayout.SOUTH);
    setSize(300, 300);
    setLocation(300, 300);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            // Run this on another thread than the AWT event queue to
            // make sure the call to Animator.stop() completes before
            // exiting
            new Thread(
                    new Runnable() {
                      public void run() {
                        stop();
                      }
                    })
                .start();
          }
        });
    setVisible(false);
  }
Example #10
0
  //    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) {
    }
  }
Example #11
0
  public static JPanel createGradientPanel() {
    JPanel gradientPanel =
        new JPanel() {
          Color c = Util.getBgColor();

          public void paintComponent(Graphics g) {
            ((Graphics2D) g)
                .setPaint(
                    new GradientPaint(0, 0, c.brighter(), getWidth(), getHeight(), c.darker()));
            g.fillRect(0, 0, getWidth(), getHeight());
          }
        };
    gradientPanel.setLayout(new BorderLayout());
    return gradientPanel;
  }
Example #12
0
 public static void drawImage(int[][][] pixels, int startX, int startY) {
   // Key idea: draw a bunch (lots of rectangles) with the appropriate color
   DrawObject R = new DrawObject();
   R.pixels = pixels;
   R.startX = startX;
   R.startY = startY;
   R.sequenceNum = currentSequenceNum;
   images.add(R);
   // Rescale if needed.
   int leftX = startX;
   int rightX = startX + pixels.length;
   int lowY = startY;
   int highY = startY + pixels[0].length;
   if (minX > leftX) {
     minX = leftX;
   }
   if (maxX < rightX) {
     maxX = rightX;
   }
   if (minY > lowY) {
     minY = lowY;
   }
   if (maxY < highY) {
     maxY = highY;
   }
   drawArea.repaint();
 }
Example #13
0
 /**
  * Adds a label that shows the percentage of hours spent on a particular project.
  *
  * @param gbl The layout to add the label to.
  * @param gbc The layout constraints to use.
  * @param row The row to link against.
  * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)}
  */
 private void addPercentLabel(GridBagLayout gbl, GridBagConstraints gbc, Row row) {
   gbc.gridx = 3;
   gbc.ipadx = 5;
   gbl.setConstraints(row.percentL, gbc);
   gbc.ipadx = 0;
   reviewPanel.add(row.percentL);
 }
  /** {@inheritDoc} */
  public void setEnabled(boolean b) {
    if (b != isEnabled()) {
      super.setEnabled(b);

      if ((selectedComponents & DISPLAY_DATE) > 0) {
        yearDecrButton.setEnabled(b);
        monthDecrButton.setEnabled(b);
        monthYearLabel.setEnabled(b);
        monthIncrButton.setEnabled(b);
        yearIncrButton.setEnabled(b);

        for (int day = 0; day < 7; day++) {
          dayOfWeekLabels[day].setEnabled(b);
        }

        for (int row = 0; row < 6; row++) {
          for (int day = 0; day < 7; day++) {
            if (dayButtons[row][day].getText().length() > 0) {
              dayButtons[row][day].setEnabled(b);
            }
          }
        }
      }

      if ((selectedComponents & DISPLAY_TIME) > 0) {
        spinner.setEnabled(b);
      }
    }
  }
Example #15
0
 static void handleMouseClick(MouseEvent e) {
   double midX = (maxX + minX) / 2;
   double midXDist = midX - minX;
   double midY = (maxY + minY) / 2;
   double midYDist = midY - minY;
   // See if any of the navigation icons were under the mouse.
   if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 10, 20)) {
     // Plus.
     setXYRange(minX, midX, minY, midY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 40, 50)) {
     // Minus.
     setXYRange(minX, 2 * maxX, minY, 2 * maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 0, 20)) {
     //
     setXYRange(minX, maxX, minY + midYDist, maxY + midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 30, 50)) {
     //
     setXYRange(minX, maxX, minY - midYDist, maxY - midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 65, D.width - 45, 20, 30)) {
     //
     setXYRange(minX + midXDist, maxX + midXDist, minY, maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 95, D.width - 75, 20, 30)) {
     //
     setXYRange(minX - midXDist, maxX - midXDist, minY, maxY);
   }
   drawArea.repaint();
 }
Example #16
0
 /**
  * Adds a simple 'h' to show that the time period is specified in hours.
  *
  * @param gbl The layout to add the label to.
  * @param gbc The layout constraints to use.
  * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)}
  */
 private void addRightLabel(GridBagLayout gbl, GridBagConstraints gbc) {
   JLabel hLabel = new JLabel("h", SwingConstants.CENTER);
   gbc.gridx = 2;
   gbc.ipadx = 5;
   gbl.setConstraints(hLabel, gbc);
   gbc.ipadx = 0;
   reviewPanel.add(hLabel);
 }
Example #17
0
 /**
  * Adds an editable text field containing the hours spent on a project.
  *
  * @param gbl The layout to add the text field to.
  * @param gbc The layout constraints to use.
  * @param row The row to link against.
  * @param hours The number of hours spent on the project.
  * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)}
  */
 private void addMiddleField(GridBagLayout gbl, GridBagConstraints gbc, Row row, double hours) {
   row.hoursTF.setText(decimalFormat.format(hours));
   gbc.gridx = 1;
   gbc.weightx = 1;
   gbl.setConstraints(row.hoursTF, gbc);
   gbc.weightx = 0;
   reviewPanel.add(row.hoursTF);
 }
Example #18
0
 static void handleKeyTyped(KeyEvent e) {
   if (e.getKeyChar() == ' ') {
     currentSequenceNumDisplay++;
     scribbles = Collections.synchronizedList(new ArrayList<DrawObject>());
     currentScribbleNum = 0;
   }
   drawArea.repaint();
 }
Example #19
0
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
    @Override
    protected void paintComponent(Graphics g) {

      super.paintComponent(g);

      if (resourceImage != null) {

        g.drawImage(resourceImage, 1, 1, this);
      }
    }
  /** {@inheritDoc} */
  public void addNotify() {
    // We don't try to do anything with the fonts until we know the
    // component is displayable

    setupTitleFont();
    setupDayOfWeekFonts();
    setupDayFonts();
    setupTimeFont();
    setupTodayFont();

    super.addNotify();
  }
Example #22
0
 public static void drawLineFromEquation(double a, double b, double c) {
   // Draw the equation ax+by+c=0 in the available range.
   DrawObject L = new DrawObject();
   L.color = lineEqnColor;
   L.a = a;
   L.b = b;
   L.c = c;
   L.sequenceNum = currentSequenceNum;
   L.drawStroke = drawStroke;
   synchronized (eqnLines) {
     eqnLines.add(L);
   }
   drawArea.repaint();
 }
 /** Applet initialization */
 public void init() {
   // Get the port to be used
   String port_str = getParameter("port");
   if (port_str != null) {
     port = Integer.parseInt(port_str);
   }
   // Try to use the system look and feel
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
   }
   // Create main panel to hold notebook
   main_panel = new JPanel();
   main_panel.setBackground(Color.white);
   main_panel.setLayout(new BorderLayout());
   setContentPane(main_panel);
   // Create the notebook
   tabbed_pane = new JTabbedPane(JTabbedPane.TOP);
   main_panel.add(tabbed_pane, BorderLayout.CENTER);
   // Add notebook page for default host connection
   pages = new Vector();
   addPage(new SOAPMonitorPage(getCodeBase().getHost()));
 }
Example #24
0
    public MonitorGUI(final PhoneCallMonitor pcm, String title) {
      this.pcm = pcm;

      text.setFont(new Font("Courier", Font.PLAIN, 12));
      text.setText(title);

      JPanel buttons = new JPanel();
      buttons.setLayout(new GridLayout(1, 0));

      button =
          new JButton(
              new AbstractAction("Pick Up" /*,new JarImageIcon(getClass(),"32x32/play.png")*/) {
                public void actionPerformed(ActionEvent ev) {
                  button.setEnabled(false);
                  pcm.pickup();
                }
              });
      buttons.add(button);

      setLayout(new BorderLayout());
      add(new JScrollPane(text), BorderLayout.CENTER);
      add(buttons, BorderLayout.SOUTH);
    }
  public void init() {
    // 添加按钮
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);

    mainPanel.setLayout(new GridLayout(0, 3));
    mainWin.add(mainPanel, BorderLayout.CENTER);

    JFormattedTextField intField0 =
        new JFormattedTextField(
            new InternationalFormatter(NumberFormat.getIntegerInstance()) {
              protected DocumentFilter getDocumentFilter() {
                return new NumberFilter();
              }
            });
    intField0.setValue(100);
    addRow("只接受数字的文本框", intField0);

    JFormattedTextField intField1 = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField1.setValue(new Integer(100));
    // 添加输入校验器
    intField1.setInputVerifier(new FormattedTextFieldVerifier());
    addRow("带输入校验器的文本框", intField1);

    // 创建自定义格式器对象
    IPAddressFormatter ipFormatter = new IPAddressFormatter();
    ipFormatter.setOverwriteMode(false);
    // 以自定义格式器对象创建格式化文本框
    JFormattedTextField ipField = new JFormattedTextField(ipFormatter);
    ipField.setValue(new byte[] {(byte) 192, (byte) 168, 4, 1});
    addRow("IP地址格式", ipField);

    mainWin.add(buttonPanel, BorderLayout.SOUTH);
    mainWin.pack();
    mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainWin.setVisible(true);
  }
Example #26
0
  /*
  public void addMiniChart(Plugin p){
  	components.add(p);

  	rebuild();
  }

  public void removeMiniChart(Plugin p){
  	components.remove(p);
  	rebuild();

  }
  */
  public void rebuild() {
    // remove everything from main panel
    mainpanel.removeAll();

    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    mainpanel.setLayout(gbl);

    gbc.anchor = gbc.NORTHWEST;
    gbc.fill = gbc.BOTH;
    gbc.weightx = 1;
    gbc.gridx = 0;

    int i = 0;
    // add chart

    gbc.weighty = 1;
    gbc.gridy = i;
    gbl.setConstraints(chartPanel, gbc);
    mainpanel.add(chartPanel);

    // add all other plugins/components
    validate();
  }
Example #27
0
 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);
   }
 }
 /**
  * Adds a row to the main panel.
  *
  * @param labelText the label of the field
  * @param field the sample field
  */
 public void addRow(String labelText, final JFormattedTextField field) {
   mainPanel.add(new JLabel(labelText));
   mainPanel.add(field);
   final JLabel valueLabel = new JLabel();
   mainPanel.add(valueLabel);
   okButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           Object value = field.getValue();
           Class<?> cl = value.getClass();
           String text = null;
           if (cl.isArray()) {
             if (cl.getComponentType().isPrimitive()) {
               try {
                 text = Arrays.class.getMethod("toString", cl).invoke(null, value).toString();
               } catch (ReflectiveOperationException ex) {
                 // ignore reflection exceptions
               }
             } else text = Arrays.toString((Object[]) value);
           } else text = value.toString();
           valueLabel.setText(text);
         }
       });
 }
 public JPanel getGuiPanel() {
   JPanel panel = new JPanel();
   JButton button = new JButton();
   button.addActionListener(new DoItListener());
   outputLabel = new JLabel("date appears here");
   DateFormatSymbols dateStuff = new DateFormatSymbols();
   month = new JComboBox(dateStuff.getMonths());
   day = new JTextField(8);
   year = new JTextField(8);
   JPanel inputPanel = new JPanel(new GridLayout(3, 2));
   inputPanel.add(new JLabel("Month"));
   inputPanel.add(month);
   inputPanel.add(new JLabel("Day"));
   inputPanel.add(day);
   inputPanel.add(new JLabel("Year"));
   inputPanel.add(button);
   inputPanel.add(outputLabel);
   return panel;
 }
Example #30
0
 public static void drawLabel(double x, double y, String str) {
   DrawObject L = new DrawObject();
   L.color = labelColor;
   L.x = x;
   L.y = y;
   L.str = str;
   L.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animLabels) {
       animLabels.add(L);
     }
   } else {
     synchronized (labels) {
       labels.add(L);
     }
   }
   drawArea.repaint();
 }