public void showItem() {

    if (!this.editorPanel.getViewer().isLanguageFunctionAvailable()) {

      return;
    }

    this.highlight =
        this.editorPanel
            .getEditor()
            .addHighlight(this.position, this.position + this.word.length(), null, true);

    final FindSynonymsActionHandler _this = this;

    QTextEditor editor = this.editorPanel.getEditor();

    Rectangle r = null;

    try {

      r = editor.modelToView(this.position);

    } catch (Exception e) {

      // BadLocationException!
      Environment.logError("Location: " + this.position + " is not valid", e);

      UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

      return;
    }

    int y = r.y;

    // Show a panel of all the items.
    final QPopup p = this.popup;

    p.setOpaque(false);

    Synonyms syns = null;

    try {

      syns = this.projectViewer.getSynonymProvider().getSynonyms(this.word);

    } catch (Exception e) {

      UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

      Environment.logError("Unable to lookup synonyms for: " + word, e);

      return;
    }

    if ((syns.words.size() == 0) && (this.word.toLowerCase().endsWith("ed"))) {

      // Trim off the ed and try again.
      try {

        syns = this.projectViewer.getSynonyms(this.word.substring(0, this.word.length() - 2));

      } catch (Exception e) {

        UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

        Environment.logError("Unable to lookup synonyms for: " + word, e);

        return;
      }
    }

    if ((syns.words.size() == 0) && (this.word.toLowerCase().endsWith("s"))) {

      // Trim off the ed and try again.
      try {

        syns = this.projectViewer.getSynonyms(this.word.substring(0, this.word.length() - 1));

      } catch (Exception e) {

        UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

        Environment.logError("Unable to lookup synonyms for: " + word, e);

        return;
      }
    }

    StringBuilder sb = new StringBuilder();

    if (syns.words.size() > 0) {

      sb.append("6px");

      for (int i = 0; i < syns.words.size(); i++) {

        if (sb.length() > 0) {

          sb.append(", ");
        }

        sb.append("p, 3px, [p,90px], 5px");
      }
      /*
                if (syns.words.size () > 0)
                {

                    sb.append (",5px");

                }
      */
    } else {

      sb.append("6px, p, 6px");
    }

    FormLayout summOnly = new FormLayout("3px, fill:380px:grow, 3px", sb.toString());
    PanelBuilder pb = new PanelBuilder(summOnly);

    CellConstraints cc = new CellConstraints();

    int ind = 2;

    Map<String, String> names = new HashMap();
    names.put(Synonyms.ADJECTIVE + "", "Adjectives");
    names.put(Synonyms.NOUN + "", "Nouns");
    names.put(Synonyms.VERB + "", "Verbs");
    names.put(Synonyms.ADVERB + "", "Adverbs");
    names.put(Synonyms.OTHER + "", "Other");

    if (syns.words.size() == 0) {

      JLabel l = new JLabel("No synonyms found.");
      l.setFont(l.getFont().deriveFont(Font.ITALIC));

      pb.add(l, cc.xy(2, 2));
    }

    // Determine what type of word we are looking for.
    for (Synonyms.Part i : syns.words) {

      JLabel l = new JLabel(names.get(i.type + ""));

      l.setFont(l.getFont().deriveFont(Font.ITALIC));
      l.setFont(l.getFont().deriveFont((float) UIUtils.getEditorFontSize(10)));
      l.setBorder(
          new CompoundBorder(
              new MatteBorder(0, 0, 1, 0, Environment.getBorderColor()),
              new EmptyBorder(0, 0, 3, 0)));

      pb.add(l, cc.xy(2, ind));

      ind += 2;

      HTMLEditorKit kit = new HTMLEditorKit();
      HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();

      JTextPane t = new JTextPane(doc);
      t.setEditorKit(kit);
      t.setEditable(false);
      t.setOpaque(false);

      StringBuilder buf =
          new StringBuilder(
              "<style>a { text-decoration: none; } a:hover { text-decoration: underline; }</style><span style='color: #000000; font-size: "
                  + ((int) UIUtils.getEditorFontSize(10) /*t.getFont ().getSize () + 2*/)
                  + "pt; font-family: "
                  + t.getFont().getFontName()
                  + ";'>");

      for (int x = 0; x < i.words.size(); x++) {

        String w = (String) i.words.get(x);

        buf.append("<a class='x' href='http://" + w + "'>" + w + "</a>");

        if (x < (i.words.size() - 1)) {

          buf.append(", ");
        }
      }

      buf.append("</span>");

      t.setText(buf.toString());

      t.addHyperlinkListener(
          new HyperlinkAdapter() {

            public void hyperlinkUpdate(HyperlinkEvent ev) {

              if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {

                QTextEditor ed = _this.editorPanel.getEditor();

                ed.replaceText(
                    _this.position, _this.position + _this.word.length(), ev.getURL().getHost());

                ed.removeHighlight(_this.highlight);

                _this.popup.setVisible(false);

                _this.projectViewer.fireProjectEvent(
                    ProjectEvent.SYNONYM, ProjectEvent.REPLACE, ev.getURL().getHost());
              }
            }
          });

      // Annoying that we have to do this but it prevents the text from being too small.

      t.setSize(new Dimension(380, Short.MAX_VALUE));

      JScrollPane sp = new JScrollPane(t);

      t.setCaretPosition(0);

      sp.setOpaque(false);
      sp.getVerticalScrollBar().setValue(0);
      /*
                  sp.setPreferredSize (t.getPreferredSize ());
                  sp.setMaximumSize (new Dimension (380,
                                                    75));
      */
      sp.getViewport().setOpaque(false);
      sp.setOpaque(false);
      sp.setBorder(null);
      sp.getViewport().setBackground(Color.WHITE);
      sp.setAlignmentX(Component.LEFT_ALIGNMENT);

      pb.add(sp, cc.xy(2, ind));

      ind += 2;
    }

    JPanel pan = pb.getPanel();
    pan.setOpaque(true);
    pan.setBackground(Color.WHITE);

    this.popup.setContent(pan);

    // r.y -= this.editorPanel.getScrollPane ().getVerticalScrollBar ().getValue ();

    Point po = SwingUtilities.convertPoint(editor, r.x, r.y, this.editorPanel);

    r.x = po.x;
    r.y = po.y;

    // Subtract the insets of the editorPanel.
    Insets ins = this.editorPanel.getInsets();

    r.x -= ins.left;
    r.y -= ins.top;

    this.editorPanel.showPopupAt(this.popup, r, "above", true);
  }
Пример #2
0
 private void jbInit() throws Exception {
   box1 = Box.createVerticalBox();
   this.getContentPane().setLayout(borderLayout1);
   close.setText("Close");
   close.addActionListener(new CellHelpWindow_close_actionAdapter(this));
   jLabel1.setText("Recommendation");
   jLabel2.setText("Description");
   jPanel1.setLayout(borderLayout2);
   jPanel2.setLayout(borderLayout3);
   description.setText("jTextPane1");
   description.setContentType("text/html");
   scp1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   scp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
   scp1.setToolTipText("");
   recom.setText("");
   recom.setContentType("text/html");
   this.getContentPane().add(box1, BorderLayout.CENTER);
   box1.add(jPanel1, null);
   box1.add(jPanel2, null);
   this.getContentPane().add(jPanel3, BorderLayout.SOUTH);
   jPanel3.add(close, null);
   jPanel2.add(jLabel1, BorderLayout.NORTH);
   jPanel2.add(scp2, BorderLayout.CENTER);
   scp2.getViewport().add(recom, null);
   jPanel2.add(scp2, BorderLayout.CENTER);
   jPanel1.add(jLabel2, BorderLayout.NORTH);
   jPanel1.add(scp1, BorderLayout.CENTER);
   scp1.getViewport().add(description, null);
 }
 private void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20);
   contentPane.setBorder(border1);
   contentPane.setLayout(borderLayout1);
   controlsPane.setLayout(gridLayout1);
   gridLayout1.setColumns(1);
   gridLayout1.setHgap(10);
   gridLayout1.setRows(0);
   gridLayout1.setVgap(10);
   okButton.setVerifyInputWhenFocusTarget(true);
   okButton.setMnemonic('O');
   okButton.setText("OK");
   buttonsPane.setLayout(flowLayout1);
   flowLayout1.setAlignment(FlowLayout.CENTER);
   messagePane.setEditable(false);
   messagePane.setText("");
   borderLayout1.setHgap(10);
   borderLayout1.setVgap(10);
   this.setTitle("Subscription Authorization");
   this.getContentPane().add(contentPane, BorderLayout.CENTER);
   contentPane.add(controlsPane, BorderLayout.SOUTH);
   controlsPane.add(responsesComboBox, null);
   controlsPane.add(buttonsPane, null);
   buttonsPane.add(okButton, null);
   contentPane.add(messageScrollPane, BorderLayout.CENTER);
   messageScrollPane.getViewport().add(messagePane, null);
 }
Пример #4
0
  void doExeCommand() {
    PSlider slider;
    Runtime program = Runtime.getRuntime();
    String currentCmd = new String();
    String X = new String();
    String Y = new String();

    // Kill the current executing program
    pid.destroy();

    // Setup the command parameters and run it
    slider = (PSlider) vSlider.elementAt(0);
    X = slider.getValue();
    slider = (PSlider) vSlider.elementAt(1);
    Y = slider.getValue();
    currentCmd = cmd + " " + X + " " + Y;

    try {
      pid = program.exec(currentCmd);
      if (isWindows == false) {
        Process pid2 = null;
        pid2 = program.exec("getpid WinSize");
      }
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      System.exit(-1);
    }

    // Update the new value in the source code of the program
    doSourceFileUpdate();
    scrollPane.getViewport().setViewPosition(new Point(0, 20));
  }
Пример #5
0
  /** @param frameName title name for frame */
  public ShowSavedResults(String frameName) {
    super(frameName);
    aboutRes =
        new JTextArea(
            "Select a result set from"
                + "\nthose listed and details"
                + "\nof that analysis will be"
                + "\nshown here. Then you can"
                + "\neither delete or view those"
                + "\nresults using the buttons below.");
    aboutScroll = new JScrollPane(aboutRes);
    ss = new JScrollPane(sp);
    ss.getViewport().setBackground(Color.white);

    //  resMenu.setLayout(new FlowLayout(FlowLayout.LEFT,10,1));
    ClassLoader cl = getClass().getClassLoader();
    rfii = new ImageIcon(cl.getResource("images/Refresh_button.gif"));

    // results status
    resButtonStatus = new JPanel(new BorderLayout());
    Border loweredbevel = BorderFactory.createLoweredBevelBorder();
    Border raisedbevel = BorderFactory.createRaisedBevelBorder();
    Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    statusField = new JTextField();
    statusField.setBorder(compound);
    statusField.setEditable(false);
  }
Пример #6
0
  public void scrollToAttribute(Attribute a) {
    if (!a.getDescriptor().getConfig().equals(getConfig())) {
      logger.fine("Cannot scroll to attribute that isn't attached to this type of descriptor");
      return;
    }
    int rowIndex = getCurrentModel().getRowForDescriptor(a.getDescriptor());
    int colIndex = getCurrentModel().getColumnForAttribute(a);
    JScrollPane scrollPane = (JScrollPane) this.getComponent(0);
    JViewport viewport = (JViewport) scrollPane.getViewport();
    EnhancedTable table = (EnhancedTable) viewport.getView();

    // This rectangle is relative to the table where the
    // northwest corner of cell (0,0) is always (0,0).
    Rectangle rect = table.getCellRect(rowIndex, colIndex, true);

    // The location of the viewport relative to the table
    Point pt = viewport.getViewPosition();

    // Translate the cell location so that it is relative
    // to the view, assuming the northwest corner of the
    // view is (0,0)
    rect.setLocation(rect.x - pt.x, rect.y - pt.y);

    // Scroll the area into view
    viewport.scrollRectToVisible(rect);
  }
Пример #7
0
  // {{{ BrowserView constructor
  BrowserView(final VFSBrowser browser) {
    this.browser = browser;

    tmpExpanded = new HashSet<String>();
    DockableWindowManager dwm = jEdit.getActiveView().getDockableWindowManager();
    KeyListener keyListener = dwm.closeListener(VFSBrowser.NAME);

    parentDirectories = new ParentDirectoryList();
    parentDirectories.addKeyListener(keyListener);
    parentDirectories.setName("parent");

    parentDirectories.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    parentDirectories.setCellRenderer(new ParentDirectoryRenderer());
    parentDirectories.setVisibleRowCount(5);
    parentDirectories.addMouseListener(new ParentMouseHandler());

    final JScrollPane parentScroller = new JScrollPane(parentDirectories);
    parentScroller.setMinimumSize(new Dimension(0, 0));

    table = new VFSDirectoryEntryTable(this);
    table.addMouseListener(new TableMouseHandler());
    table.addKeyListener(new TableKeyListener());
    table.setName("file");
    JScrollPane tableScroller = new JScrollPane(table);
    tableScroller.setMinimumSize(new Dimension(0, 0));
    tableScroller.getViewport().setBackground(table.getBackground());
    tableScroller.getViewport().addMouseListener(new TableMouseHandler());
    splitPane =
        new JSplitPane(
            browser.isHorizontalLayout() ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT,
            parentScroller,
            tableScroller);
    splitPane.setOneTouchExpandable(true);

    EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            String prop =
                browser.isHorizontalLayout()
                    ? "vfs.browser.horizontalSplitter"
                    : "vfs.browser.splitter";
            int loc = jEdit.getIntegerProperty(prop, -1);
            if (loc == -1) loc = parentScroller.getPreferredSize().height;

            splitPane.setDividerLocation(loc);
            parentDirectories.ensureIndexIsVisible(parentDirectories.getModel().getSize());
          }
        });

    if (browser.isMultipleSelectionEnabled())
      table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    else table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    setLayout(new BorderLayout());

    add(BorderLayout.CENTER, splitPane);

    propertiesChanged();
  } // }}}
Пример #8
0
  /** {@inheritDoc} */
  @Override
  public void mouseDragged(final MouseEvent aEvent) {
    final MouseEvent event = convertEvent(aEvent);
    final Point point = event.getPoint();

    // Update the selected channel while dragging...
    this.controller.setSelectedChannel(point);

    if (getModel().isCursorMode() && (this.movingCursor >= 0)) {
      this.controller.moveCursor(this.movingCursor, getCursorDropPoint(point));

      aEvent.consume();
    } else {
      if ((this.lastClickPosition == null)
          && ((aEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)) {
        this.lastClickPosition = new Point(point);
      }

      final JScrollPane scrollPane =
          getAncestorOfClass(JScrollPane.class, (Component) aEvent.getSource());
      if ((scrollPane != null) && (this.lastClickPosition != null)) {
        final JViewport viewPort = scrollPane.getViewport();
        final Component signalView = this.controller.getSignalDiagram().getSignalView();

        boolean horizontalOnly = (aEvent.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0;
        boolean verticalOnly =
            horizontalOnly && ((aEvent.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0);

        int dx = aEvent.getX() - this.lastClickPosition.x;
        int dy = aEvent.getY() - this.lastClickPosition.y;

        Point scrollPosition = viewPort.getViewPosition();
        int newX = scrollPosition.x;
        if (!verticalOnly) {
          newX -= dx;
        }
        int newY = scrollPosition.y;
        if (verticalOnly || !horizontalOnly) {
          newY -= dy;
        }

        int diagramWidth = signalView.getWidth();
        int viewportWidth = viewPort.getWidth();
        int maxX = diagramWidth - viewportWidth - 1;
        scrollPosition.x = Math.max(0, Math.min(maxX, newX));

        int diagramHeight = signalView.getHeight();
        int viewportHeight = viewPort.getHeight();
        int maxY = diagramHeight - viewportHeight;
        scrollPosition.y = Math.max(0, Math.min(maxY, newY));

        viewPort.setViewPosition(scrollPosition);
      }

      // Use UNCONVERTED/ORIGINAL mouse event!
      handleZoomRegion(aEvent, this.lastClickPosition);
    }
  }
Пример #9
0
 private void ensureRowIsVisible(int nRow) {
   Rectangle visibleRect = table.getCellRect(nRow, 0, true);
   if (debugSetPath) System.out.println("----ensureRowIsVisible = " + visibleRect);
   if (visibleRect != null) {
     visibleRect.x = scrollPane.getViewport().getViewPosition().x;
     table.scrollRectToVisible(visibleRect);
     table.repaint();
   }
 }
 /**
  * Set the view of the scrollable picture to show the map location
  *
  * @param mapLocation "(x, y)"
  */
 public void setView(String mapLocation) {
   int x = Integer.parseInt(mapLocation.substring(1, mapLocation.indexOf(',')));
   int y =
       Integer.parseInt(
           mapLocation.substring(mapLocation.indexOf(", ") + 2, mapLocation.length() - 1));
   Point point =
       new Point(x - (mapScrollPane.getWidth() / 2), y - (mapScrollPane.getHeight() / 2));
   map.showLocation(true, x, y);
   mapScrollPane.getViewport().setViewPosition(point);
 }
Пример #11
0
  void doExeCommand() {
    JViewport viewport = scrollPane.getViewport();
    String strContent = new String();
    PSlider slider;
    int i;
    File fp = new File(dataFile);

    RandomAccessFile access = null;
    Runtime program = Runtime.getRuntime();
    String cmdTrigger = "trigger";

    boolean delete = fp.delete();

    try {
      fp.createNewFile();
    } catch (IOException ie) {
      System.err.println("Couldn't create the new file " + ie);
      // System.exit(-1);;
    }

    try {
      access = new RandomAccessFile(fp, "rw");
    } catch (IOException ie) {
      System.err.println("Error in accessing the file " + ie);
      // System.exit(-1);;
    }

    for (i = 0; i < COMPONENTS; i++) {
      slider = (PSlider) vSlider.elementAt(i);
      /* Modified on March 20th to satisfy advisors' new request */
      if (slider.isString == true) strContent = strContent + slider.getRealStringValue() + " ";
      else strContent = strContent + slider.getValue() + " ";
    }

    // Get value of the radio button group
    if (firstBox.isSelected() == true) strContent = strContent + "1";
    else strContent = strContent + "0";

    try {
      access.writeBytes(strContent);
      access.close();
    } catch (IOException ie) {
      System.err.println("Error in writing to file " + ie);
      // System.exit(-1);;
    }
    // Trigger the OpenGL program to update with new values
    try {
      Process pid = program.exec(cmdTrigger);
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      // System.exit(-1);;
    }
    doSourceFileUpdate();
  }
Пример #12
0
 /**
  * Static Init
  *
  * @throws Exception
  */
 void jbInit() throws Exception {
   mainPanel.setLayout(mainLayout);
   mainLayout.setHgap(2);
   mainLayout.setVgap(2);
   infoPane.setBorder(BorderFactory.createLoweredBevelBorder());
   infoPane.setPreferredSize(new Dimension(500, 400));
   getContentPane().add(mainPanel);
   mainPanel.add(infoPane, BorderLayout.CENTER);
   mainPanel.add(confirmPanel, BorderLayout.SOUTH);
   infoPane.getViewport().add(info, null);
   confirmPanel.addActionListener(this);
 } //	jbInit
Пример #13
0
 public void actionPerformed(ActionEvent e) {
   String item = (String) displaySelector.getSelectedItem();
   treeMode = item;
   // We want to respond to the changing of the combobox selectio
   if (item == PBTREE_ID) {
     // Display the tree
     treeScroller.getViewport().setView(treeView);
   } else if (item == STRAT_ID) {
     // Display strategies
     treeScroller.getViewport().setView(stratView);
   } else if (item == FORM_ID) {
     // Display formations
     treeScroller.getViewport().setView(formView);
   } else if (item == ROLE_ID) {
     // Display roles
     treeScroller.getViewport().setView(roleView);
   } else if (item == SUBROLE_ID) {
     // Display SubRoles
     treeScroller.getViewport().setView(subRoleView);
   }
 }
Пример #14
0
  void updateList() {
    if (runned) {
      empty.removeAll();
      list = new CheckBoxList(field.getClusters(), field.getNoise(), this);

      JScrollPane sp = new JScrollPane();
      sp.getViewport().add(list);
      empty.add(sp);
      sp.repaint();
      empty.validate();
    }
  }
Пример #15
0
  /**
   * Method loads a PlayBook and displays its members to the screen
   *
   * @param book The PlayBook to be loaded in
   */
  protected void loadPlayBook(PlayBookEditor editor) throws IOException {
    this.editor = editor;
    ComponentLibrary myCompLib = editor.getComponentLibrary();
    // We setup the various display units for the play book components
    treeView = new JTree(editor.getPlayBook());
    stratView = new JList(myCompLib.strategies);
    formView = new JList(myCompLib.formations);
    roleView = new JList(myCompLib.roles);
    subRoleView = new JList(myCompLib.subRoles);

    // Set default display to tree
    treeScroller.getViewport().setView(treeView);
  }
Пример #16
0
 private void jbInit() throws Exception {
   titledBorder1 = new TitledBorder("");
   this.setLayout(borderLayout1);
   this.setBorder(titledBorder1);
   titledBorder1.setTitleColor(Color.blue);
   titledBorder1.setTitle(
       ClientSettings.getInstance().getResources().getResource("documents filter"));
   this.add(sp, BorderLayout.CENTER);
   sp.setBorder(BorderFactory.createEmptyBorder());
   sp.getViewport().add(innerPanel, null);
   sp.setAutoscrolls(true);
   innerPanel.setLayout(gridBagLayout1);
 }
Пример #17
0
  @SuppressWarnings("OverridableMethodCallInConstructor")
  Notepad() {
    super(true);

    // Trying to set Nimbus look and feel
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception ignored) {
    }

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor = createEditor();
    // Add this as a listener for undoable edits.
    editor.getDocument().addUndoableEditListener(undoHandler);

    // install the command table
    commands = new HashMap<Object, Action>();
    Action[] actions = getActions();
    for (Action a : actions) {
      commands.put(a.getValue(Action.NAME), a);
    }

    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
    port.add(editor);

    String vpFlag = getProperty("ViewportBackingStore");
    if (vpFlag != null) {
      Boolean bs = Boolean.valueOf(vpFlag);
      port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE);
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add("North", createToolbar());
    panel.add("Center", scroller);
    add("Center", panel);
    add("South", createStatusbar());
  }
Пример #18
0
  private void setupWindowAndListeners() {
    // Initialize Objects
    title = new JLabel("Coordinated Behavior Tree", JLabel.CENTER);
    treeScroller = new JScrollPane();
    treeNodes = new Vector<PBTreeNode>();
    treeView = new JTree(treeNodes);
    stratView = new JList();
    formView = new JList();
    roleView = new JList();
    subRoleView = new JList();

    // Setup our display selection drop down list
    selectorList = new Vector<String>();
    selectorList.add(PBTREE_ID);
    selectorList.add(STRAT_ID);
    selectorList.add(FORM_ID);
    selectorList.add(ROLE_ID);
    selectorList.add(SUBROLE_ID);
    displaySelector = new JComboBox(selectorList);
    displaySelector.addActionListener(this);
    treeScroller.getViewport().setView(treeView);
    treeMode = PBTREE_ID;
    treeScroller.setFocusable(false);
    treeScroller.addMouseListener(this);
    subRoleView.addMouseListener(this);

    // Setup Layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);

    // Add Items
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(title, c);
    c.gridheight = 2;
    add(title);

    gridbag.setConstraints(displaySelector, c);
    add(displaySelector);

    c.gridheight = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(treeScroller, c);
    add(treeScroller);
  }
Пример #19
0
  /**
   * @param aEvent
   * @param aStartPoint
   */
  protected void handleZoomRegion(final MouseEvent aEvent, final Point aStartPoint) {
    // For now, disabled by default as it isn't 100% working yet...
    if (Boolean.FALSE.equals(Boolean.valueOf(System.getProperty("zoomregionenabled", "false")))) {
      return;
    }

    final JComponent source = (JComponent) aEvent.getComponent();
    final boolean dragging = (aEvent.getID() == MouseEvent.MOUSE_DRAGGED);

    final GhostGlassPane glassPane =
        (GhostGlassPane) SwingUtilities.getRootPane(source).getGlassPane();

    Rectangle viewRect;
    final JScrollPane scrollPane =
        SwingComponentUtils.getAncestorOfClass(JScrollPane.class, source);
    if (scrollPane != null) {
      final JViewport viewport = scrollPane.getViewport();
      viewRect = SwingUtilities.convertRectangle(viewport, viewport.getVisibleRect(), glassPane);
    } else {
      viewRect = SwingUtilities.convertRectangle(source, source.getVisibleRect(), glassPane);
    }

    final Point start = SwingUtilities.convertPoint(source, aStartPoint, glassPane);
    final Point current = SwingUtilities.convertPoint(source, aEvent.getPoint(), glassPane);

    if (dragging) {
      if (!glassPane.isVisible()) {
        glassPane.setVisible(true);
        glassPane.setRenderer(new RubberBandRenderer(), start, current, viewRect);
      } else {
        glassPane.updateRenderer(start, current, viewRect);
      }

      glassPane.repaintPartially();
    } else
    /* if ( !dragging ) */
    {
      // Fire off a signal to the zoom controller to do its job...
      this.controller.getZoomController().zoomRegion(aStartPoint, aEvent.getPoint());

      glassPane.setVisible(false);
    }
  }
Пример #20
0
 private void jbInit() throws Exception {
   panel1.setLayout(borderLayout1);
   okButton.setText("OK");
   okButton.addActionListener(new MimeTypeEditor_okButton_actionAdapter(this));
   filtersTable.setRowSelectionAllowed(true);
   filtersTable.setPreferredSize(new Dimension(418, 200));
   filtersTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
   filtersTable.setCellSelectionEnabled(true);
   filtersTable.setColumnSelectionAllowed(false);
   filtersTable.setModel(m_model);
   addButton.setToolTipText(
       "Add a new " + mimeTypeEditorBuilder.getValueName() + " for a MIME type");
   addButton.setText("Add");
   addButton.addActionListener(new MimeTypeEditor_addButton_actionAdapter(this));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(new MimeTypeEditor_cancelButton_actionAdapter(this));
   deleteButton.setToolTipText("Delete the currently selected item.");
   deleteButton.setText("Delete");
   deleteButton.addActionListener(new MimeTypeEditor_deleteButton_actionAdapter(this));
   upButton.setText("Up");
   upButton.addActionListener(new MimeTypeEditor_upButton_actionAdapter(this));
   dnButton.setText("Down");
   dnButton.addActionListener(new MimeTypeEditor_dnButton_actionAdapter(this));
   panel1.setPreferredSize(new Dimension(418, 200));
   jScrollPane1.setMinimumSize(new Dimension(200, 80));
   jScrollPane1.setOpaque(true);
   buttonPanel.add(dnButton, null);
   buttonPanel.add(upButton, null);
   buttonPanel.add(addButton, null);
   buttonPanel.add(deleteButton, null);
   buttonPanel.add(okButton, null);
   buttonPanel.add(cancelButton, null);
   getContentPane().add(panel1);
   panel1.add(buttonPanel, BorderLayout.SOUTH);
   panel1.add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(filtersTable, null);
 }
  /**
   * Method to check that the current position is in the viewing area and if not scroll to center
   * the current position if possible
   */
  public void checkScroll() {
    // get the x and y position in pixels
    int xPos = (int) (colIndex * zoomFactor);
    int yPos = (int) (rowIndex * zoomFactor);

    // only do this if the image is larger than normal
    if (zoomFactor > 1) {

      // get the rectangle that defines the current view
      JViewport viewport = scrollPane.getViewport();
      Rectangle rect = viewport.getViewRect();
      int rectMinX = (int) rect.getX();
      int rectWidth = (int) rect.getWidth();
      int rectMaxX = rectMinX + rectWidth - 1;
      int rectMinY = (int) rect.getY();
      int rectHeight = (int) rect.getHeight();
      int rectMaxY = rectMinY + rectHeight - 1;

      // get the maximum possible x and y index
      int macolIndexX = (int) (picture.getWidth() * zoomFactor) - rectWidth - 1;
      int macolIndexY = (int) (picture.getHeight() * zoomFactor) - rectHeight - 1;

      // calculate how to position the current position in the middle of the viewing
      // area
      int viewX = xPos - (int) (rectWidth / 2);
      int viewY = yPos - (int) (rectHeight / 2);

      // reposition the viewX and viewY if outside allowed values
      if (viewX < 0) viewX = 0;
      else if (viewX > macolIndexX) viewX = macolIndexX;
      if (viewY < 0) viewY = 0;
      else if (viewY > macolIndexY) viewY = macolIndexY;

      // move the viewport upper left point
      viewport.scrollRectToVisible(new Rectangle(viewX, viewY, rectWidth, rectHeight));
    }
  }
Пример #22
0
  public void installUI(JComponent c) {
    searchnav = (JHelpSearchNavigator) c;
    HelpModel helpmodel = searchnav.getModel();

    searchnav.setLayout(new BorderLayout());
    searchnav.addPropertyChangeListener(this);
    searchnav.addComponentListener(this);
    if (helpmodel != null) {
      helpmodel.addHelpModelListener(this);
    }

    JLabel search =
        new JLabel(HelpUtilities.getString(HelpUtilities.getLocale(c), "search.findLabel"));
    searchparams = new JTextField("", 20);
    search.setLabelFor(searchparams);
    searchparams.addActionListener(searchAction);

    JPanel box = new JPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(search);
    box.add(searchparams);

    searchnav.add("North", box);
    topNode = new DefaultMutableTreeNode();
    lastTOCnode = null;
    tree = new JTree(topNode);
    // public String convertValueToText(Object val
    TreeSelectionModel tsm = tree.getSelectionModel();
    tsm.addTreeSelectionListener(this);
    tree.setShowsRootHandles(false);
    tree.setRootVisible(false);
    sp = new JScrollPane();
    sp.getViewport().add(tree);
    searchnav.add("Center", sp);
    reloadData();
  }
 private Context saveContext() {
   Rectangle rect = myScrollPane.getViewport().getViewRect();
   return new Context(myElement, myText, rect);
 }
Пример #24
0
  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));
  }
Пример #25
0
  private void jbInit() throws Exception {
    titledBorder1 = new TitledBorder("");
    this.setLayout(baseLayout);

    double[][] lower_size = {
      {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL}
    };
    mLowerPanelLayout = new TableLayout(lower_size);

    mLowerPanel.setLayout(mLowerPanelLayout);

    double[][] dir_size = {
      {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL}
    };
    mDirectionsPanelLayout = new TableLayout(dir_size);
    mDirectionsPanel.setLayout(mDirectionsPanelLayout);

    // Try to get icons for the toolbar buttons
    try {
      ClassLoader loader = getClass().getClassLoader();
      mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif"));
      mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif"));
      mDisabledRemoveIcon =
          new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif"));

      mAddNodeBtn.setIcon(mAddIcon);
      mRemoveNodeBtn.setIcon(mRemoveIcon);
      mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon);
    } catch (Exception e) {
      // Ack! No icons. Use text labels instead
      mAddNodeBtn.setText("Add");
      mRemoveNodeBtn.setText("Remove");
    }

    /*
    mAddNodeBtn.setMaximumSize(new Dimension(130, 33));
    mAddNodeBtn.setMinimumSize(new Dimension(130, 33));
    mAddNodeBtn.setPreferredSize(new Dimension(130, 33));
    mAddNodeBtn.setText("Add Node");
    */
    mAddNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    /*
    mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33));
    mRemoveNodeBtn.setText("Remove Node");
    */
    mRemoveNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mRemoveNode();
          }
        });
    mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING);
    mHostnameLabel.setLabelFor(mHostnameField);
    mHostnameLabel.setText("Hostname:");

    mHostnameField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder());
    mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20));
    mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER);
    mTitleLabel.setText("Add Cluster Nodes");
    mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration.");
    mDirectionsLabel.setLineWrap(true);
    mDirectionsLabel.setEditable(false);
    mDirectionsLabel.setBackground(mTitleLabel.getBackground());

    baseLayout.setHgap(5);
    baseLayout.setVgap(5);
    mLowerPanel.add(
        mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mListScrollPane1,
        new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mLowerPanel, BorderLayout.CENTER);
    mListScrollPane1.getViewport().add(lstNodes, null);
    mDirectionsPanel.add(
        mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mDirectionsLabel,
        new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mDirectionsPanel, BorderLayout.NORTH);
  }
Пример #26
0
 void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5);
   panel1.setLayout(borderLayout1);
   jPanel1.setLayout(borderLayout2);
   jScrollPane1.getViewport().setBackground(Color.white);
   jPanel2.setLayout(gridBagLayout1);
   jLabel1.setText("Profile Name : ");
   nameTextField.setMinimumSize(new Dimension(4, 18));
   nameTextField.setPreferredSize(new Dimension(63, 18));
   jLabel2.setText("Profile Type : ");
   openButton.setMaximumSize(new Dimension(73, 24));
   openButton.setMinimumSize(new Dimension(73, 24));
   openButton.setPreferredSize(new Dimension(73, 24));
   openButton.setText("Open");
   openButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           openButton_actionPerformed(e);
         }
       });
   cancelButton.setMaximumSize(new Dimension(73, 24));
   cancelButton.setMinimumSize(new Dimension(73, 24));
   cancelButton.setPreferredSize(new Dimension(73, 24));
   cancelButton.setMargin(new Insets(0, 5, 0, 5));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           cancelButton_actionPerformed(e);
         }
       });
   profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   profileList.addMouseListener(
       new java.awt.event.MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           profileList_mouseClicked(e);
         }
       });
   jPanel2.setBorder(border1);
   typeComboBox.setMaximumSize(new Dimension(32767, 18));
   typeComboBox.setMinimumSize(new Dimension(122, 18));
   typeComboBox.setPreferredSize(new Dimension(176, 18));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jScrollPane1, BorderLayout.CENTER);
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel1,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 7, 0),
           0,
           0));
   jPanel2.add(
       nameTextField,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 7, 0),
           0,
           0));
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 17, 0),
           0,
           0));
   jScrollPane1.getViewport().add(profileList, null);
   jPanel2.add(
       openButton,
       new GridBagConstraints(
           3,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 2, 10),
           0,
           0));
   jPanel2.add(
       cancelButton,
       new GridBagConstraints(
           3,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 9, 10),
           0,
           0));
   jPanel2.add(
       typeComboBox,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 17, 0),
           0,
           0));
 }
Пример #27
0
  // gui constructor
  public Gui() throws IOException {

    // sets frame text and features
    super("Doge Clicker 1.0");
    this.setIconImage(new ImageIcon("Images//doge.jpg").getImage());

    // initializes sound files
    Sounds.initialize();

    // gui dimensions and features
    setSize(1000, 700);
    setResizable(false);
    setLayout(null);
    Container c = getContentPane();
    c.setBackground(new Color(255, 255, 255));
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    // timer for doge per second run method runs every millisecond
    timer = new Timer();
    timer.schedule(new RemindTask(), 1000, 10);

    // bolded title
    title = new JLabel("Doge Clicker v1.0");
    title.setBounds(0, 0, getWidth(), 40);
    title.setFont(new Font("Comic Sans MS", Font.BOLD, 26));
    title.setForeground(Color.white);
    title.setHorizontalAlignment(JLabel.CENTER);
    add(title);

    // reads news.txt to have import text to array
    String filePath = "Data\\news.txt";
    BufferedReader fileIn = new BufferedReader(new FileReader(filePath));
    for (int i = 0; i < line.length; i++) {

      // reads lines and saves until done reading
      if ((line[i] = fileIn.readLine()) != null) {}
    }
    fileIn.close(); // close file

    // read flavor text.txt to import text to array
    filePath = "Data\\flavourtext.txt";
    fileIn = new BufferedReader(new FileReader(filePath));
    for (int i = 0; i < flavourText.length; i++) {

      // reads lines until complety reading
      if ((flavourText[i] = fileIn.readLine()) != null) {}
    }
    fileIn.close();

    // flavour label that pops up randomly when doge is clicked
    flavourClick = new JLabel("Wow! Such click!");
    flavourClick.setBounds(400, 100, getWidth(), getHeight());
    flavourClick.setFont(new Font("Comic Sans MS", Font.BOLD, 25));
    flavourClick.setForeground(Color.white);
    flavourClick.setOpaque(false);
    add(flavourClick);

    // label for achievements
    achievementText = new JLabel("These are your achievements");
    achievementText.setBounds(75, 2, getWidth(), 15);
    achievementText.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    achievementText.setForeground(Color.white);
    add(achievementText);

    // label for doge buying and click upgrades
    dogeProducers = new JLabel("Buy to make more doge");
    dogeProducers.setBounds(50, 160, getWidth(), 40);
    dogeProducers.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    dogeProducers.setForeground(Color.white);
    add(dogeProducers);
    dogeClickers = new JLabel("Miscellaneous upgrades wow");
    dogeClickers.setBounds(700, 160, getWidth(), 40);
    dogeClickers.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    dogeClickers.setForeground(Color.white);
    add(dogeClickers);

    // doge click button
    dogeClick = new JButton(new ImageIcon("Images/doge.jpg"));
    dogeClick.addActionListener(this);
    dogeClick.setBounds(450, 100, 100, 100);
    dogeClick.setOpaque(false);
    dogeClick.setBorder(BorderFactory.createLineBorder(Color.black));
    dogeClick.setToolTipText("Each click gives you " + clickUpgrade + " doge. wow");
    add(dogeClick);

    // click multiplier
    clickMultiplier = new JLabel(multiplier + "x");
    clickMultiplier.setBounds(570, 120, getWidth(), 50);
    clickMultiplier.setFont(new Font("Comic Sans MS", Font.BOLD, 30));
    clickMultiplier.setForeground(Color.white);
    add(clickMultiplier);
    // clicks per second indicator
    cpsIndicator = new JLabel(cps + " clicks per second");
    cpsIndicator.setBounds(570, 150, getWidth(), 50);
    cpsIndicator.setFont(new Font("Comic Sans MS", Font.BOLD, 10));
    cpsIndicator.setForeground(Color.white);
    add(cpsIndicator);

    // event indicator
    eventIndicator = new JLabel("Welcome to doge clicker!");
    eventIndicator.setBounds(700, 530, getWidth(), 50);
    eventIndicator.setFont(new Font("Comic Sans MS", Font.BOLD, 15));
    eventIndicator.setForeground(Color.white);
    add(eventIndicator);

    // states the num of doge and doge per second
    dogeCount = new JLabel("Doge: " + doge);
    dogeCount.setBounds(0, 0, getWidth(), 120);
    dogeCount.setFont(new Font("Comic Sans MS", Font.BOLD, 20));
    dogeCount.setForeground(Color.white);
    dogeCount.setHorizontalAlignment(JLabel.CENTER);
    add(dogeCount);
    dogePerSecond = new JLabel("You get " + dps + " doge per second");
    dogePerSecond.setBounds(0, 25, getWidth(), 120);
    dogePerSecond.setFont(new Font("Comic Sans MS", Font.BOLD, 11));
    dogePerSecond.setForeground(Color.white);
    dogePerSecond.setHorizontalAlignment(JLabel.CENTER);
    add(dogePerSecond);
    dogeClicktext = new JLabel("Click for more doge");
    dogeClicktext.setBounds(400, 185, 200, 50);
    dogeClicktext.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    dogeClicktext.setForeground(Color.white);
    dogeClicktext.setHorizontalAlignment(JLabel.CENTER);
    add(dogeClicktext);
    // doge button testing button
    devButton = new JButton(new ImageIcon());
    devButton.addActionListener(this);
    devButton.setBounds(0, 0, 50, 50);
    devButton.setToolTipText("Such Secret");
    devButton.setOpaque(false);
    devButton.setContentAreaFilled(false);
    devButton.setBorderPainted(false);
    add(devButton);

    // options and save buttons
    options = new JButton(new ImageIcon("Images/option.png"));
    options.addActionListener(this);
    options.setBounds(900, 10, 70, 70);
    options.setOpaque(false);
    options.setBorder(BorderFactory.createLineBorder(Color.black));
    options.setToolTipText("Go to options");
    add(options);
    save = new JButton(new ImageIcon("Images/save.png"));
    save.addActionListener(this);
    save.setBounds(820, 10, 70, 70);
    save.setOpaque(false);
    save.setBorder(BorderFactory.createLineBorder(Color.black));
    save.setToolTipText("Save a file");
    add(save);
    open = new JButton(new ImageIcon("Images/open.png"));
    open.addActionListener(this);
    open.setBounds(740, 10, 70, 70);
    open.setOpaque(false);
    open.setBorder(BorderFactory.createLineBorder(Color.black));
    open.setToolTipText("Open a file");
    add(open);

    // news headline label that will move
    for (int i = 0; i < 3; i++) {

      newsHeadline[i] = new JLabel("Welcome to Doge clicker this is a news headline!");
      newsHeadline[i].setBounds(-200 - (475 * i), 615, getWidth(), 40);
      newsHeadline[i].setFont(new Font("Comic Sans MS", Font.BOLD, 13));
      newsHeadline[i].setForeground(Color.white);
      add(newsHeadline[i]);
    }

    // create all buttons and button stats and labels for producers
    for (int i = 0; i < MAX_UPGRADES; i++) {

      producerStats[i] = new Producers(i);
      producers[i] = new JButton(new ImageIcon(producerStats[i].getImage()));
      producers[i].addActionListener(this);
      producers[i].setOpaque(false);
      producers[i].setBorder(BorderFactory.createLineBorder(Color.black));
      producers[i].setToolTipText(
          "Your "
              + producerStats[i].getButtonName()
              + " gives "
              + producerStats[i].getDogeProduction() * producerStats[i].getCount()
              + " doge per second");
      producers[i].setBounds(0, 0, 70, 70);

      buyProducers[i] =
          new JLabel(
              "Buy "
                  + producerStats[i].getButtonName()
                  + " for "
                  + producerStats[i].getCost()
                  + " doge");
      buyProducers[i].setBounds(0, 0, getWidth(), 100);
      buyProducers[i].setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
      buyProducers[i].setForeground(Color.white);

      buyDetails[i] =
          new JLabel(
              "You have: " + producerStats[i].getCount() + " " + producerStats[i].getButtonName());
      buyDetails[i].setBounds(0, 0, getWidth(), 100);
      buyDetails[i].setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
      buyDetails[i].setForeground(Color.white);
    }
    // buttons and labels for click upgrades clickers
    for (int i = 0; i < MAX_CLICK; i++) {

      clickerStats[i] = new Clickers(i);
      clickers[i] = new JButton(new ImageIcon(clickerStats[i].getImage()));
      clickers[i].addActionListener(this);
      if (clickerStats[i].getClickMultiplier() == 1) {
        clickers[i].setToolTipText(
            "Buy this "
                + clickerStats[i].getButtonName()
                + " to get +"
                + clickerStats[i].getClickBonus()
                + " doge per click");
      } else {
        clickers[i].setToolTipText(
            "Buy this "
                + clickerStats[i].getButtonName()
                + " to get x"
                + clickerStats[i].getClickMultiplier()
                + " doge per click");
      }
      clickers[i].setOpaque(false);
      clickers[i].setBorder(BorderFactory.createLineBorder(Color.black));
      clickers[i].setBounds(0, 0, 70, 70);

      buyClickers[i] =
          new JLabel(
              "Buy "
                  + clickerStats[i].getButtonName()
                  + " for "
                  + clickerStats[i].getCost()
                  + " doge");
      buyClickers[i].setBounds(0, 0, getWidth(), 100);
      buyClickers[i].setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
      buyClickers[i].setForeground(Color.white);
    }

    // labels for achievements
    for (int i = 0; i < MAX_ACHIEVEMENTS; i++) {
      achievementStats[i] = new Achievements(i);
      achievements[i] = new JLabel(new ImageIcon(achievementStats[i].getImage()));
      achievements[i].setBorder(BorderFactory.createLineBorder(Color.black));
      achievements[i].setToolTipText("Achievement: " + achievementStats[i].getButtonName());
      achievements[i].setBounds(0, 0, 70, 70);
    }

    // JPanel containing achievements
    JPanel achievementPanel = new JPanel();
    achievementPanel.setPreferredSize(new Dimension(350, 70));
    achievementPanel.setLayout(null);
    achievementPanel.setOpaque(false);

    // JScrollpane containing JPanel for achievements
    JScrollPane achievementDisplay = new JScrollPane();
    achievementDisplay.setViewportBorder(new LineBorder(Color.black));
    achievementDisplay.setSize(280, 90);
    achievementDisplay.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    achievementDisplay.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    achievementDisplay.getVerticalScrollBar().setUnitIncrement(10);
    achievementDisplay.setLocation(50, 20);
    achievementDisplay.setOpaque(false);
    add(achievementDisplay);

    // adds the panel
    achievementDisplay.getViewport().add(achievementPanel);
    achievementDisplay.getViewport().setOpaque(false);

    // adds all achievements
    for (int i = 0; i < MAX_ACHIEVEMENTS; i++) {

      achievementPanel.add(achievements[i]);
      achievements[i].setLocation(0 + i * 70, 0);
      achievements[i].setVisible(false);
    }

    // jpanel containing upgrades for producers
    JPanel upgradePanel = new JPanel();
    upgradePanel.setPreferredSize(new Dimension(350, 770));
    upgradePanel.setLayout(null);
    upgradePanel.setOpaque(false);

    // Jscrollpane containing jpanel for producers
    JScrollPane producerUpgrades = new JScrollPane();
    producerUpgrades.setViewportBorder(new LineBorder(Color.black));
    producerUpgrades.setSize(350, 300);
    producerUpgrades.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    producerUpgrades.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    producerUpgrades.getVerticalScrollBar().setUnitIncrement(10);
    producerUpgrades.setLocation(0, 200);
    producerUpgrades.setOpaque(false);
    add(producerUpgrades);

    producerUpgrades.getViewport().setOpaque(false);
    producerUpgrades.getViewport().add(upgradePanel);

    // adds all upgrades
    for (int i = 0; i < MAX_UPGRADES; i++) {

      upgradePanel.add(producers[i]);
      producers[i].setLocation(0, (i) * 70);
      upgradePanel.add(buyProducers[i]);
      buyProducers[i].setLocation(90, (i * 70) - 35);
      upgradePanel.add(buyDetails[i]);
      buyDetails[i].setLocation(90, (i * 70) - 20);
    }

    // jpanel containing upgrades for clickers
    JPanel clickPanel = new JPanel();
    clickPanel.setPreferredSize(new Dimension(350, 350));
    clickPanel.setLayout(null);
    clickPanel.setOpaque(false);

    // Jscrollpane containing jpanel for clickers
    JScrollPane clickUpgrades = new JScrollPane();
    clickUpgrades.setViewportBorder(new LineBorder(Color.black));
    clickUpgrades.setSize(350, 300);
    clickUpgrades.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    clickUpgrades.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    clickUpgrades.getVerticalScrollBar().setUnitIncrement(10);
    clickUpgrades.setLocation(650, 200);
    clickUpgrades.setOpaque(false);
    add(clickUpgrades);
    clickUpgrades.getViewport().add(clickPanel);
    clickUpgrades.getViewport().setOpaque(false);

    // adds all click upgrades
    for (int i = 0; i < MAX_CLICK; i++) {

      clickPanel.add(clickers[i]);
      clickers[i].setLocation(0, (i) * 70);
      clickPanel.add(buyClickers[i]);
      buyClickers[i].setLocation(80, (i * 70) - 30);
    }

    // dancing snoop dog image
    JLabel snoop = new JLabel(new ImageIcon("Images//snoop.gif"));
    snoop.setBounds(450, 370, 150, 308);
    snoop.setOpaque(false);
    add(snoop);

    // background image
    JLabel background = new JLabel(new ImageIcon("Images//dogebackground.png"));
    background.setBounds(0, 0, 1000, 700);
    add(background);

    // makes everything above visible
    setVisible(true);
    // flavour click will remain invisible
    flavourClick.setVisible(false);

    // timer for news headline, runs every 20 milliseconds
    MyTimerTask task = new MyTimerTask();
    Timer newsTimer = new Timer();
    newsTimer.scheduleAtFixedRate(task, 0, 20);
  }
Пример #28
0
  /* Build up the GUI using Swing magic. Nothing very exciting here - the
  BagPanel class makes the code a bit cleaner/easier to read. */
  private void guiInit() throws Exception {
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setMinimumSize(new Dimension(500, 250));
    mainPanel.setPreferredSize(new Dimension(500, 300));

    /* The message area */
    JScrollPane mssgPanel = new JScrollPane();
    mssgPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    mssgPanel.setAutoscrolls(true);
    mssgArea = new JTextArea();
    mssgArea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 20));
    mainPanel.add(mssgPanel, BorderLayout.CENTER);
    mssgPanel.getViewport().add(mssgArea, null);

    /* The button area */
    BagPanel buttonPanel = new BagPanel();
    GridBagConstraints c = buttonPanel.c;

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;

    buttonPanel.makeLabel("Detection", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    detDarkCb = buttonPanel.makeCheckBox("Dark", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    detAccelCb = buttonPanel.makeCheckBox("Movement", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Theft Reports", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repLedCb = buttonPanel.makeCheckBox("LED", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repSirenCb = buttonPanel.makeCheckBox("Siren", false);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repServerCb = buttonPanel.makeCheckBox("Server", false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repNeighboursCb = buttonPanel.makeCheckBox("Neighbours", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Interval", JLabel.CENTER);
    fieldInterval = buttonPanel.makeTextField(10, null);
    fieldInterval.setText(Integer.toString(Constants.DEFAULT_CHECK_INTERVAL));

    ActionListener settingsAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateSettings();
          }
        };
    buttonPanel.makeButton("Update", settingsAction);

    mainPanel.add(buttonPanel, BorderLayout.EAST);

    /* The frame part */
    frame = new JFrame("AntiTheft");
    frame.setSize(mainPanel.getPreferredSize());
    frame.getContentPane().add(mainPanel);
    frame.setVisible(true);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
Пример #29
0
  public void run() {
    WindowBlocker blocker = new WindowBlocker(NearInfinity.getInstance());
    blocker.setBlocked(true);
    List<ResourceEntry> creFiles = ResourceFactory.getInstance().getResources("CRE");
    creFiles.addAll(ResourceFactory.getInstance().getResources("CHR"));
    ProgressMonitor progress =
        new ProgressMonitor(
            NearInfinity.getInstance(), "Checking inventories...", null, 0, creFiles.size());
    table =
        new SortableTable(
            new String[] {"File", "Name", "Item", "Message"},
            new Class[] {Object.class, Object.class, Object.class, Object.class},
            new int[] {100, 100, 200, 200});
    for (int i = 0; i < creFiles.size(); i++) {
      ResourceEntry entry = creFiles.get(i);
      try {
        if (typeButtons[0].isSelected())
          checkCreatureInventory((CreResource) ResourceFactory.getResource(entry));
        if (typeButtons[1].isSelected())
          checkItemAttribute((CreResource) ResourceFactory.getResource(entry));
      } catch (Exception e) {
        e.printStackTrace();
      }
      progress.setProgress(i + 1);
      if (progress.isCanceled()) {
        JOptionPane.showMessageDialog(
            NearInfinity.getInstance(),
            "Operation canceled",
            "Info",
            JOptionPane.INFORMATION_MESSAGE);
        blocker.setBlocked(false);
        return;
      }
    }

    if (table.getRowCount() == 0)
      JOptionPane.showMessageDialog(
          NearInfinity.getInstance(), "No hits found", "Info", JOptionPane.INFORMATION_MESSAGE);
    else {
      resultFrame = new ChildFrame("Result of CRE inventory check", true);
      resultFrame.setIconImage(Icons.getIcon("Refresh16.gif").getImage());
      bopen = new JButton("Open", Icons.getIcon("Open16.gif"));
      bopennew = new JButton("Open in new window", Icons.getIcon("Open16.gif"));
      JLabel count = new JLabel(table.getRowCount() + " hit(s) found", JLabel.CENTER);
      count.setFont(count.getFont().deriveFont((float) count.getFont().getSize() + 2.0f));
      bopen.setMnemonic('o');
      bopennew.setMnemonic('n');
      resultFrame.getRootPane().setDefaultButton(bopennew);
      JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
      panel.add(bopen);
      panel.add(bopennew);
      JScrollPane scrollTable = new JScrollPane(table);
      scrollTable.getViewport().setBackground(table.getBackground());
      JPanel pane = (JPanel) resultFrame.getContentPane();
      pane.setLayout(new BorderLayout(0, 3));
      pane.add(count, BorderLayout.NORTH);
      pane.add(scrollTable, BorderLayout.CENTER);
      pane.add(panel, BorderLayout.SOUTH);
      bopen.setEnabled(false);
      bopennew.setEnabled(false);
      table.setFont(BrowserMenuBar.getInstance().getScriptFont());
      table.getSelectionModel().addListSelectionListener(this);
      table.addMouseListener(
          new MouseAdapter() {
            public void mouseReleased(MouseEvent event) {
              if (event.getClickCount() == 2) {
                int row = table.getSelectedRow();
                if (row != -1) {
                  ResourceEntry resourceEntry = (ResourceEntry) table.getValueAt(row, 0);
                  Resource resource = ResourceFactory.getResource(resourceEntry);
                  new ViewFrame(resultFrame, resource);
                  ((AbstractStruct) resource)
                      .getViewer()
                      .selectEntry(((Item) table.getValueAt(row, 2)).getName());
                }
              }
            }
          });
      bopen.addActionListener(this);
      bopennew.addActionListener(this);
      pane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
      resultFrame.pack();
      Center.center(resultFrame, NearInfinity.getInstance().getBounds());
      resultFrame.setVisible(true);
    }
    blocker.setBlocked(false);
    //    for (int i = 0; i < table.getRowCount(); i++) {
    //      CreInvError error = (CreInvError)table.getTableItemAt(i);
    //      System.out.println(error.resourceEntry + " (" + error.resourceEntry.getSearchString() +
    // ") -> " + error.itemRef.getAttribute("Item"));
    //    }
  }
  /** Creates a ComponentTree, loading the Components from the file at <code>path</code>. */
  public ComponentTree(String path) {
    this.path = path;
    ttCount++;
    jTextArea = new JTextArea();
    textArea = new JTextArea();
    redirectSystemStreams();
    frame = createFrame();
    Container cPane = frame.getContentPane();
    JMenuBar mb = createMenuBar();
    TreeTableModel model = createModel(path);

    cPane.setLayout(new BorderLayout(5, 5));
    Dimension dim = new Dimension(600, 600);
    cPane.setPreferredSize(dim);

    try {
      textArea.read(new FileReader(path), null);
    } catch (IOException e) {
      e.printStackTrace(); // To change body of catch statement use File | Settings | File
      // Templates.
    }
    treeTable = createTreeTable(model);
    textArea.setEditable(false);

    JScrollPane tp =
        new JScrollPane(
            textArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JScrollPane sp =
        new JScrollPane(
            treeTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JScrollPane cp =
        new JScrollPane(
            jTextArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    sp.getViewport().setBackground(Color.white);

    Dimension scrDim = new Dimension(300, 600);
    Dimension dime = new Dimension(300, 400);
    Dimension dimc = new Dimension(300, 200);
    sp.setLocation(0, 0);
    sp.setPreferredSize(dime);
    tp.setLocation(300, 0);
    tp.setPreferredSize(scrDim);
    cp.setLocation(0, 400);
    cp.setPreferredSize(dimc);
    cPane.add(sp, BorderLayout.LINE_START);
    cPane.add(tp, BorderLayout.CENTER);
    cPane.add(cp, BorderLayout.PAGE_END);
    cPane.setPreferredSize(dim);

    // frame.add(cPane);
    frame.setJMenuBar(mb);
    // frame.pack();

    frame.setVisible(true);
  }