Beispiel #1
0
 @Override
 public void patchCompleted(PatchCompletionEvent pce) throws InterruptedException {
   long now = System.currentTimeMillis();
   long sleepTime = 100 - (now - lastRedraw);
   if (sleepTime > 0) Thread.sleep(sleepTime);
   testPanel.redraw(pce.getImage());
   lastRedraw = now;
 }
  /** {@code [a,q[r,s]] - > [a[q[r[s]]]] } */
  @Test
  public void panel1() {
    MarkupContainer a = new A(), r = new R(), s = new S();

    TestPanel q = new TestPanel("q");
    q.setPanelMarkup("<wicket:panel><p wicket:id='r'><p wicket:id='s'></p></p></wicket:panel>");
    q.queue(r, s);

    TestPage p = new TestPage();
    p.setPageMarkup("<p wicket:id='a'><p wicket:id='q'></p></p>");

    p.queue(a, q);

    tester.startPage(p);

    assertThat(p, hasPath(new Path(a, q, r, s)));
  }
  /** panel has leading markup */
  @Test
  public void panel2() {
    MarkupContainer r = new R();

    TestPanel q = new TestPanel("q");
    q.setPanelMarkup(
        "<html><body><wicket:panel><p wicket:id='r'></p></wicket:panel></body></html>");
    q.queue(r);

    TestPage p = new TestPage();
    p.setPageMarkup("<p wicket:id='q'></p>");
    p.queue(q);

    tester.startPage(p);

    assertThat(p, hasPath(new Path(q, r)));
  }
  /** panel with a static header section */
  @Test
  public void panel3() {
    MarkupContainer r = new R();

    TestPanel q = new TestPanel("q");
    q.setPanelMarkup(
        "<html><head><wicket:head><meta/></wicket:head></head>"
            + "<body><wicket:panel><p wicket:id='r'></p></wicket:panel></body></html>");
    q.queue(r);

    TestPage p = new TestPage();
    p.setPageMarkup("<html><head></head><body><p wicket:id='q'></p></body></html>");
    p.queue(q);

    tester.startPage(p);

    assertThat(p, hasPath(new Path(q, r)));
    tester.assertContains("<meta/>"); // contributed by <wicket:head>
  }
  // Fill this panel with nine panels of different colors.
  public TestUnicodeMap() {

    // Title this frame.
    super("Text Test");

    // Make this exit when the close button is clicked.
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            quit();
          }
        });

    // Create the Export dialog.
    dialog = new ExportDialog();

    // Make a menu bar and menu.
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu("File");
    JMenu page = new JMenu("Page");
    JMenu font = new JMenu("Font");

    // Add a menu item which will bring up this dialog.
    JMenuItem export = new JMenuItem("Export...");
    export.addActionListener(this);
    file.add(export);
    file.addSeparator();

    // Quit menu item.
    JMenuItem quit = new JMenuItem("Quit");
    quit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            quit();
          }
        });
    file.add(quit);

    // Latin menu item.
    JMenuItem item = new JMenuItem("Latin");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setStartString("\u0000");
            symbols.setEndString("\u00ff");
            symbols.repaint();
          }
        });
    page.add(item);

    item = new JMenuItem("Greek");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setStartString("\u0300");
            symbols.setEndString("\u03ff");
            symbols.repaint();
          }
        });
    page.add(item);

    item = new JMenuItem("Punctuation");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setStartString("\u2000");
            symbols.setEndString("\u20ff");
            symbols.repaint();
          }
        });
    page.add(item);

    item = new JMenuItem("Arrows");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setStartString("\u2100");
            symbols.setEndString("\u21ff");
            symbols.repaint();
          }
        });
    page.add(item);

    item = new JMenuItem("MathOps");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setStartString("\u2200");
            symbols.setEndString("\u22ff");
            symbols.repaint();
          }
        });
    page.add(item);

    item = new JMenuItem("Dingbats");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setStartString("\u2700");
            symbols.setEndString("\u27ff");
            symbols.repaint();
          }
        });
    page.add(item);

    item = new JMenuItem("Courier");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setFont("courier");
            repaint();
          }
        });
    font.add(item);

    item = new JMenuItem("Times");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setFont("serif");
            repaint();
          }
        });
    font.add(item);

    item = new JMenuItem("Helvetica");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            symbols.setFont("sansserif");
            repaint();
          }
        });
    font.add(item);

    // Add this to the frame.
    menuBar.add(file);
    menuBar.add(page);
    menuBar.add(font);
    setJMenuBar(menuBar);

    // Get the content pane.
    Container content = this.getContentPane();

    // Set the layout of this panel.
    content.setLayout(new BorderLayout());

    // Create a border of white surrounded by black.
    Border border =
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(1, 1, 1, 1, Color.white),
            BorderFactory.createMatteBorder(2, 2, 2, 2, Color.black));

    // Create a subpanel to hold the symbol panel.
    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    symbols = new TestPanel();
    symbols.setBorder(border);
    panel.add(symbols);

    // Add this panel to this container.
    content.add(panel, BorderLayout.CENTER);
  }