Esempio n. 1
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
Esempio n. 2
0
 private JPanel getUIPanel() {
   JButton button = new JButton("change data");
   JRadioButton[] rbs = new JRadioButton[5];
   final ButtonGroup group = new ButtonGroup();
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           int index = Integer.parseInt(group.getSelection().getActionCommand());
           double xMin = -MAX, xMax = MAX, yMin = -MAX, yMax = MAX;
           switch (index) {
             case 0:
               xMax = -5;
               break;
             case 1:
               xMin = 5;
               break;
             case 2:
               break;
             case 3:
               yMax = -5;
               break;
             case 4:
               yMin = 5;
           }
           double[] x = getData(xMin, xMax);
           double[] y = getData(yMin, yMax);
           plotPanel.setData(x, y);
         }
       });
   JPanel panel = new JPanel(new GridBagLayout());
   GridBagConstraints gbc = new GridBagConstraints();
   String minus = "<html>\u2013";
   String[] ids = {"<html>\u2013x", "+x", "<html>+/\u2013x&y", "<html>\u2013y", "+y"};
   for (int i = 0; i < rbs.length; i++) {
     rbs[i] = new JRadioButton(ids[i], i == 2);
     rbs[i].setActionCommand(String.valueOf(i));
     group.add(rbs[i]);
     panel.add(rbs[i], gbc);
   }
   panel.setBorder(BorderFactory.createEtchedBorder());
   gbc.weightx = 1.0;
   panel.add(button, gbc);
   return panel;
 }
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   int w = getWidth();
   int h = getHeight();
   // Draw ordinate.
   g2.draw(new Line2D.Double(Points, Points, Points, h - Points));
   // Draw abcissa.
   g2.draw(new Line2D.Double(Points, h - Points, w - Points, h - Points));
   // Draw labels.
   Font font = g2.getFont();
   FontRenderContext frc = g2.getFontRenderContext();
   LineMetrics lm = font.getLineMetrics("0", frc);
   float sh = lm.getAscent() + lm.getDescent();
   // Ordinate label.
   String s = "Strecke";
   float sy = Points + ((h - 2 * Points) - s.length() * sh) / 2 + lm.getAscent();
   for (int i = 0; i < s.length(); i++) {
     String letter = String.valueOf(s.charAt(i));
     float sw = (float) font.getStringBounds(letter, frc).getWidth();
     float sx = (Points - sw) / 2;
     g2.drawString(letter, sx, sy);
     sy += sh;
   }
   // Abcissa label.
   s = "Datum";
   sy = h - Points + (Points - sh) / 2 + lm.getAscent();
   float sw = (float) font.getStringBounds(s, frc).getWidth();
   float sx = (w - sw) / 2;
   g2.drawString(s, sx, sy);
   // Draw lines.
   double xInc = (double) (w - 2 * Points) / (data.length - 1);
   double scale = (double) (h - 2 * Points) / getMax();
   g2.setPaint(Color.green.darker());
   for (int i = 0; i < data.length - 1; i++) {
     double x1 = Points + i * xInc;
     double y1 = h - Points - scale * data[i];
     double x2 = Points + (i + 1) * xInc;
     double y2 = h - Points - scale * data[i + 1];
     g2.draw(new Line2D.Double(x1, y1, x2, y2));
   }
   // Mark data points.
   g2.setPaint(Color.red);
   for (int i = 0; i < data.length; i++) {
     double x = Points + i * xInc;
     double y = h - Points - scale * data[i];
     g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4));
   }
 }
Esempio n. 4
0
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(
       RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
   Font font = g2.getFont();
   FontRenderContext frc = g2.getFontRenderContext();
   float y = PAD;
   for (int j = 0; j < data.length; j++) {
     for (int k = 0; k < data[j].length; k++) {
       String s = data[j][k];
       LineMetrics lm = font.getLineMetrics(s, frc);
       float x = PAD + offsets[j][k];
       y += lm.getAscent();
       g2.drawString(s, x, y);
       y += lm.getDescent();
     }
   }
 }
Esempio n. 5
0
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int w = getWidth();
    int h = getHeight();
    double xScale = (w - 2 * PAD) / (xMax - xMin);
    double yScale = (h - 2 * PAD) / (yMax - yMin);
    if (firstTime) System.out.printf("xScale = %.1f  yScale = %.1f%n", xScale, yScale);
    Point2D.Double origin = new Point2D.Double(); // Axes origin.
    Point2D.Double offset = new Point2D.Double(); // Locate data.
    if (xMax < 0) {
      origin.x = w - PAD;
      offset.x = origin.x - xScale * xMax;
    } else if (xMin < 0) {
      origin.x = PAD - xScale * xMin;
      offset.x = origin.x;
    } else {
      origin.x = PAD;
      offset.x = PAD - xScale * xMin;
    }
    if (yMax < 0) {
      origin.y = h - PAD;
      offset.y = origin.y - yScale * yMax;
    } else if (yMin < 0) {
      origin.y = PAD - yScale * yMin;
      offset.y = origin.y;
    } else {
      origin.y = PAD;
      offset.y = PAD - yScale * yMin;
    }
    if (firstTime) {
      System.out.printf("origin = [%6.1f, %6.1f]%n", origin.x, origin.y);
      System.out.printf("offset = [%6.1f, %6.1f]%n", offset.x, offset.y);
    }

    // Draw abcissa.
    g2.draw(new Line2D.Double(PAD, origin.y, w - PAD, origin.y));
    // Draw ordinate.
    g2.draw(new Line2D.Double(origin.x, PAD, origin.x, h - PAD));
    g2.setPaint(Color.red);
    // Mark origin.
    g2.fill(new Ellipse2D.Double(origin.x - 2, origin.y - 2, 4, 4));

    // Plot data.
    g2.setPaint(Color.blue);
    for (int i = 0; i < x.length; i++) {
      double x1 = offset.x + xScale * x[i];
      double y1 = offset.y + yScale * y[i];
      if (firstTime) System.out.printf("i = %d  x1 = %6.1f  y1 = %.1f%n", i, x1, y1);
      g2.fill(new Ellipse2D.Double(x1 - 2, y1 - 2, 4, 4));
      g2.drawString(String.valueOf(i), (float) x1 + 3, (float) y1 - 3);
    }

    // Draw extreme data values.
    g2.setPaint(Color.black);
    Font font = g2.getFont();
    FontRenderContext frc = g2.getFontRenderContext();
    LineMetrics lm = font.getLineMetrics("0", frc);
    String s = String.format("%.1f", xMin);
    float width = (float) font.getStringBounds(s, frc).getWidth();
    double x = offset.x + xScale * xMin;
    g2.drawString(s, (float) x, (float) origin.y + lm.getAscent());
    s = String.format("%.1f", xMax);
    width = (float) font.getStringBounds(s, frc).getWidth();
    x = offset.x + xScale * xMax;
    g2.drawString(s, (float) x - width, (float) origin.y + lm.getAscent());
    s = String.format("%.1f", yMin);
    width = (float) font.getStringBounds(s, frc).getWidth();
    double y = offset.y + yScale * yMin;
    g2.drawString(s, (float) origin.x + 1, (float) y + lm.getAscent());
    s = String.format("%.1f", yMax);
    width = (float) font.getStringBounds(s, frc).getWidth();
    y = offset.y + yScale * yMax;
    g2.drawString(s, (float) origin.x + 1, (float) y);
    if (firstTime) System.out.println("------------------------------");
    firstTime = false;
  }
Esempio n. 6
0
 public void geInit() {
   JopSpider.setSystemName("䣷D‘ú·D‘ú·p—uÄŸ¢·{¨· s¨·È‡Æ¿ç韷D‘ú·D‘ú·x—u s¨·");
   engine.setAnimationScanTime(500);
   engine.setScanTime(500);
   size = new Dimension(711, 169);
   Dimension dsize = new Dimension(localPanel.original_width, localPanel.original_height);
   this.addComponentListener(new AspectRatioListener(this, size));
   contentPane = (JPanel) this.getContentPane();
   contentPane.setLayout(borderLayout1);
   if (scrollbar) contentPane.add(new JScrollPane(localPanel), BorderLayout.CENTER);
   else contentPane.add(localPanel, BorderLayout.CENTER);
   contentPane.setOpaque(true);
   localPanel.setLayout(new RatioLayout()); // scaletest
   localPanel.setOpaque(true);
   localPanel.setBackground(GeColor.getColor(51, GeColor.NO_COLOR));
   this.setSize(size);
   if (engine.isInstance()) setTitle(engine.getInstance());
   else this.setTitle("JopcMessagehandler");
   pwr_indsquare2 = new pwr_indsquare(session);
   pwr_indsquare2.setBounds(new Rectangle(133, 78, 15, 16));
   localPanel.add(pwr_indsquare2, new Proportion(pwr_indsquare2.getBounds(), dsize));
   pwr_indsquare3 = new pwr_indsquare(session);
   pwr_indsquare3.setBounds(new Rectangle(133, 99, 15, 16));
   localPanel.add(pwr_indsquare3, new Proportion(pwr_indsquare3.getBounds(), dsize));
   pwr_valuelong4 = new pwr_valuelong(session);
   pwr_valuelong4.setBounds(new Rectangle(151, 77, 535, 17));
   pwr_valuelong4.setBorderColor(33);
   localPanel.add(pwr_valuelong4, new Proportion(pwr_valuelong4.getBounds(), dsize));
   pwr_valuelong5 = new pwr_valuelong(session);
   pwr_valuelong5.setBounds(new Rectangle(151, 99, 535, 17));
   pwr_valuelong5.setBorderColor(33);
   localPanel.add(pwr_valuelong5, new Proportion(pwr_valuelong5.getBounds(), dsize));
   pwr_valuesmall7 = new pwr_valuesmall(session);
   pwr_valuesmall7.setBounds(new Rectangle(133, 10, 54, 17));
   pwr_valuesmall7.setFillColor(31);
   pwr_valuesmall7.setBorderColor(33);
   localPanel.add(pwr_valuesmall7, new Proportion(pwr_valuesmall7.getBounds(), dsize));
   pwr_valuesmall9 = new pwr_valuesmall(session);
   pwr_valuesmall9.setBounds(new Rectangle(133, 31, 54, 17));
   pwr_valuesmall9.setFillColor(31);
   pwr_valuesmall9.setBorderColor(33);
   localPanel.add(pwr_valuesmall9, new Proportion(pwr_valuesmall9.getBounds(), dsize));
   pwr_valuesmall11 = new pwr_valuesmall(session);
   pwr_valuesmall11.setBounds(new Rectangle(133, 54, 54, 17));
   pwr_valuesmall11.setFillColor(31);
   pwr_valuesmall11.setBorderColor(33);
   localPanel.add(pwr_valuesmall11, new Proportion(pwr_valuesmall11.getBounds(), dsize));
   pwr_indsquare2.dd.setDynType(33554432);
   pwr_indsquare2.dd.setActionType(0);
   pwr_indsquare2.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynStatusColor(pwr_indsquare2.dd, "$node.ProcStatus[6]##status", 38)
       });
   pwr_indsquare3.dd.setDynType(33554432);
   pwr_indsquare3.dd.setActionType(0);
   pwr_indsquare3.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynStatusColor(pwr_indsquare3.dd, "$node.ProcMsgSeverity[6]##status", 38)
       });
   pwr_valuelong4.dd.setDynType(1025);
   pwr_valuelong4.dd.setActionType(0);
   pwr_valuelong4.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuelong4.dd, "$node.ProcStatus[6]##Status", "%1m")
       });
   pwr_valuelong5.dd.setDynType(1025);
   pwr_valuelong5.dd.setActionType(0);
   pwr_valuelong5.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuelong5.dd, "$node.ProcMessage[6]##String80", "%s")
       });
   pwr_valuesmall7.dd.setDynType(1025);
   pwr_valuesmall7.dd.setActionType(0);
   pwr_valuesmall7.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuesmall7.dd, "$object.EventListSize##Int32", "%d")
       });
   pwr_valuesmall9.dd.setDynType(1025);
   pwr_valuesmall9.dd.setActionType(0);
   pwr_valuesmall9.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuesmall9.dd, "$object.EventLogSize##Int32", "%d")
       });
   pwr_valuesmall11.dd.setDynType(1025);
   pwr_valuesmall11.dd.setActionType(0);
   pwr_valuesmall11.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuesmall11.dd, "$object.MaxApplAlarms##Int32", "%d")
       });
   engine.setFrameReady();
 }