Пример #1
0
  private void browseItem(DiscoverItems.Item discoveredItem) {
    addAddress(discoveredItem.getEntityID());
    browsePanel.removeAll();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
    DiscoverItems result;
    try {
      result = discoManager.discoverItems(discoveredItem.getEntityID());
    } catch (XMPPException e) {
      browsePanel.invalidate();
      browsePanel.validate();
      browsePanel.repaint();
      return;
    }

    Iterator<DiscoverItems.Item> discoverItems = result.getItems();
    List<Entity> list = new ArrayList<Entity>();

    while (discoverItems.hasNext()) {
      DiscoverItems.Item item = discoverItems.next();
      Entity entity = new Entity(item);
      browsePanel.add(entity);
      list.add(entity);
    }

    GraphicUtils.makeSameSize((JComponent[]) list.toArray(new JComponent[list.size()]));

    browsePanel.invalidate();
    browsePanel.validate();
    browsePanel.repaint();
  }
Пример #2
0
    public void setFolderViewed(String folderViewed, String notesFile) {
      this.folderViewed = folderViewed;
      this.notesFile = notesFile;

      if (folderViewed == null || notesFile == null) {
        JLabel noLabel = new JLabel("No notes available at this level");
        notespane.setLayout(new BoxLayout(notespane, BoxLayout.PAGE_AXIS));
        notespane.removeAll();
        notespane.add(Box.createVerticalGlue());
        notespane.add(noLabel);
        notespane.add(Box.createVerticalGlue());
      } else {
        File folder = new File(this.folderViewed);
        File notes = new File(this.notesFile);

        notesLabel.setText(notes.getAbsolutePath());
        notespane.setLayout(new BorderLayout());
        notespane.removeAll();

        notespane.add(editor);
        if (notes.exists()) editor.open(notes);
        fileRepository.setFolder(folder);
      }
      notespane.invalidate();
      notespane.validate();
      this.repaint();
    }
Пример #3
0
  private void browse(String serviceName) {
    browsePanel.removeAll();

    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
    DiscoverItems result;
    try {
      result = discoManager.discoverItems(serviceName);
    } catch (XMPPException e) {
      Log.error(e);
      return;
    }

    addAddress(serviceName);

    Iterator<DiscoverItems.Item> discoverItems = result.getItems();
    while (discoverItems.hasNext()) {
      DiscoverItems.Item item = discoverItems.next();
      Entity entity = new Entity(item);
      browsePanel.add(entity);
    }

    browsePanel.invalidate();
    browsePanel.validate();
    browsePanel.repaint();
  }
Пример #4
0
 /**
  * Action of family radio button MultisensorItemPanel {@literal &} IndicatorTOItem must overrides
  */
 protected void setFamily(String family) {
   _family = family;
   if (log.isDebugEnabled()) {
     log.debug("setFamily: for type \"" + _itemType + "\", family \"" + family + "\"");
   }
   _iconFamilyPanel.remove(_iconPanel);
   _iconPanel = new JPanel(new FlowLayout());
   _iconFamilyPanel.add(_iconPanel, 0);
   HashMap<String, NamedIcon> map = ItemPalette.getIconMap(_itemType, _family);
   if (map != null) {
     _currentIconMap = map;
   }
   if (!_supressDragging) {
     _iconFamilyPanel.remove(_dragIconPanel);
     _dragIconPanel = new JPanel(new FlowLayout());
     _iconFamilyPanel.add(_dragIconPanel, 0);
     makeDndIconPanel(_currentIconMap, "BeanStateUnknown");
   }
   addIconsToPanel(_currentIconMap);
   _iconFamilyPanel.invalidate();
   hideIcons();
   Enumeration<AbstractButton> en = _familyButtonGroup.getElements();
   while (en.hasMoreElements()) {
     JRadioButton but = (JRadioButton) en.nextElement();
     if (_family != null && _family.equals(but.getText())) {
       but.setSelected(true);
       break;
     }
   }
 }
  void setNetworkView(final CyNetworkView view) {
    getApplyBtn().setEnabled(view != null);

    if (layoutAttrPnl == null) return;

    layoutAttrPnl.removeAll();
    layoutAttrTunable = new LayoutAttributeTunable();

    if (view != null) {
      List<String> attributeList =
          getAttributeList(
              view.getModel(),
              currentLayout.getSupportedNodeAttributeTypes(),
              currentLayout.getSupportedEdgeAttributeTypes());

      if (attributeList.size() > 0) {
        layoutAttrTunable.layoutAttribute = new ListSingleSelection<String>(attributeList);
        layoutAttrTunable.layoutAttribute.setSelectedValue(attributeList.get(0));

        final PanelTaskManager taskMgr = serviceRegistrar.getService(PanelTaskManager.class);
        JPanel panel = taskMgr.getConfiguration(null, layoutAttrTunable);
        setPanelsTransparent(panel);
        layoutAttrPnl.add(panel);
        panel.invalidate();
      }
    }
  }
Пример #6
0
 /**
  * Remove the currently display gui and insert the given one.
  *
  * @param comp The new gui.
  */
 private void addToContents(JComponent comp) {
   treePanel.removeAll();
   comp.setPreferredSize(new Dimension(200, 300));
   treePanel.add(comp, BorderLayout.CENTER);
   if (contents != null) {
     contents.invalidate();
     contents.validate();
     contents.repaint();
   }
 }
Пример #7
0
 /**
  * Remove the currently display gui and insert the given one.
  *
  * @param comp The new gui.
  */
 private void addToContents(JComponent comp) {
   handlerHolder.removeAll();
   comp.setPreferredSize(new Dimension(200, 300));
   handlerHolder.add(comp, BorderLayout.CENTER);
   if (myContents != null) {
     myContents.invalidate();
     myContents.validate();
     myContents.repaint();
   }
 }
Пример #8
0
  void showCurrentRoll() {
    attackerText.setText(attackerDesc() + " " + battlePhaseDesc());

    diceBox.setVisible(false);

    hitBox.removeAll();
    hitBox.setVisible(false);
    missBox.removeAll();
    missBox.setVisible(false);

    if (strikerDesc().equals("")) {
      diceBoxTitledBorder.setTitle("Attack results");
    } else {
      diceBoxTitledBorder.setTitle(
          "("
              + currentEntry
              + " of "
              + (diceResults.size() - 1)
              + ") "
              + strikerDesc()
              + " attacks "
              + targetDesc()
              + " (target number is "
              + targetNumber()
              + ")");
    }

    if (numDice() > 0) {
      dice = new Chit[numDice()];

      for (int i = 0; i < numDice(); i++) {
        String imageName = getDieImageName(rolls().get(i));
        if (imageName != null) {
          dice[i] = Chit.newDiceChit(2 * Scale.get(), imageName);
          if (averageMiss() > i) {
            missBox.add(dice[i]);
          } else {
            hitBox.add(dice[i]);
          }
        }
      }

      if (averageMiss() < numDice()) {
        hitBox.setVisible(true);
      }
      if (averageMiss() > 0) {
        missBox.setVisible(true);
      }
    } else {
      dice = null;
    }

    diceBox.invalidate();
    diceBox.setVisible(true);
  }
Пример #9
0
 protected void showIcons() {
   if (!jmri.util.ThreadingUtil.isGUIThread())
     log.error("Not on GUI thread", new Exception("traceback"));
   _iconPanel.setVisible(true);
   _iconPanel.invalidate();
   if (!_supressDragging) {
     _dragIconPanel.setVisible(false);
   }
   _showIconsButton.setText(Bundle.getMessage("HideIcons"));
   reset();
   closeDialogs();
 }
 void show(
     String description,
     String failureMessage,
     ConcreteDiagram cd,
     int SIZE,
     boolean useColors) {
   JPanel jp = new CirclesPanel(description, failureMessage, cd, useColors);
   p.removeAll();
   p.invalidate();
   p.add(jp);
   p.revalidate();
   getContentPane().repaint();
 }
Пример #11
0
  protected void setButtons(String[] options) {
    buttons = new RaplaButton[options.length];

    for (int i = 0; i < options.length; i++) {
      buttons[i] = new RaplaButton(options[i], RaplaButton.DEFAULT);
      buttons[i].addActionListener(buttonListener);
      buttons[i].setAction(abortAction);
      buttons[i].setDefaultCapable(true);
    }
    jPanelButtonFrame.removeAll();
    jPanelButtonFrame.add(createButtonPanel());
    if (options.length > 0) setDefault(0);
    jPanelButtonFrame.invalidate();
  }
Пример #12
0
 protected void updateFamiliesPanel() {
   if (log.isDebugEnabled()) {
     log.debug("updateFamiliesPanel for " + _itemType);
   }
   if (_iconFamilyPanel != null) {
     removeIconFamiliesPanel();
   }
   initIconFamiliesPanel();
   add(_iconFamilyPanel, _buttonPostion);
   hideIcons();
   _iconFamilyPanel.invalidate();
   invalidate();
   reset();
 }
Пример #13
0
 // @pre: param key is key of the bottom-most row in kvp
 public void removeBottomRow(String key) {
   if (keysVisible) {
     kvpPanel.remove(keyKeyComponentMap.remove(key));
   }
   kvpPanel.remove(keyValueComponentMap.remove(key));
   for (JPanel j : keyExtraComponentsMap.remove(key)) {
     kvpPanel.remove(j);
   }
   kvpPanel.remove(keyDetailComponentMap.remove(key));
   for (GridBagConstraints c : columnConstraints) {
     c.gridy--;
   }
   keyDetailConstraints.gridy--;
   kvpPanel.invalidate();
   kvpPanel.updateUI();
 }
Пример #14
0
  public void dispose() {
    disposing = true;
    // remove utilities
    if (currentPageChanger != null) {
      currentPageChanger.dispose();
    }
    if (keyListenerPageChanger != null) {
      keyListenerPageChanger.uninstall();
    }

    // trigger a re-layout
    pagesPanel.removeAll();
    pagesPanel.invalidate();

    // make sure we call super.
    super.dispose();
  }
  public void motionTableClicked() {
    if (!refreshing) {
      if (motionPropertyPnl != null) {
        motionPropertyRootPnl.remove(motionPropertyPnl);
        motionPropertyPnl = null;
      }
      if (project.getMotions().size() > 0
          && motionTable.getSelectedRow() >= 0
          && motionTable.getSelectedRow() < project.getMotions().size()) {
        Motion motion = project.getMotions().get(motionTable.getSelectedRow());

        @SuppressWarnings("rawtypes")
        Map<Class, PropertyEditor> editors = new HashMap<Class, PropertyEditor>();
        editors.put(Motion.class, new MotionTypeEditor(project.getMotions()));

        motionPropertyPnl = new PropertyPanel(motion, editors);

        motionPropertyPnl.setDescriptionVisible(false);

        PropertyChangeListener listener =
            new PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent evt) {
                refreshing = true;
                try {
                  int oldSel = motionTable.getSelectedRow();
                  refreshMotionTable();
                  motionTable.getSelectionModel().setSelectionInterval(oldSel, oldSel);
                  enableControls();
                } finally {
                  refreshing = false;
                }
              }
            };
        motionPropertyPnl.addPropertySheetChangeListener(listener);

        motionPropertyRootPnl.add(motionPropertyPnl, BorderLayout.CENTER);
        enableControls();
      }
    }
    refreshMotionLinksTable();
    motionPropertyRootPnl.invalidate();
    motionPropertyRootPnl.validate();
  }
Пример #16
0
  /** Set the button vcomponent */
  private void setButton() {
    int pos = 55;

    for (int i = 0; i < names.length; i++) {
      pos += 30;
      JButton topicBtn = new JButton();
      topicBtn.setText(((VoteTopic) names[i]).getTitle());
      topicBtn.addActionListener(new ActionSelect());
      dynamicButtons.put(((VoteTopic) names[i]).getTitle(), topicBtn);
      topicBtn.setBounds(20, pos, 379, 30);
      contentPane.add(topicBtn);
      if (i == (names.length - 1)) {
        lastPos = pos;
      }
    }

    contentPane.invalidate();
    contentPane.repaint();
  }
 /** Update any UI elements from the model (hint that data has changed). */
 public void updateFromModel() {
   if (ColorAndFontConstants.isInverse()) {
     inactiveBackGroundColor =
         new Color(
             Math.min(255, Themes.currentTheme.detailPanelBackground().getRed() + 2 * COLOR_DELTA),
             Math.min(
                 255, Themes.currentTheme.detailPanelBackground().getBlue() + 2 * COLOR_DELTA),
             Math.min(
                 255, Themes.currentTheme.detailPanelBackground().getGreen() + 2 * COLOR_DELTA));
   } else {
     inactiveBackGroundColor =
         new Color(
             Math.max(0, Themes.currentTheme.detailPanelBackground().getRed() - COLOR_DELTA),
             Math.max(0, Themes.currentTheme.detailPanelBackground().getBlue() - COLOR_DELTA),
             Math.max(0, Themes.currentTheme.detailPanelBackground().getGreen() - COLOR_DELTA));
   }
   panelMain.invalidate();
   panelMain.revalidate();
   panelMain.repaint();
 }
  public static void setPlayerEnabled(boolean value) {
    if (COMPONENT != null && value == COMPONENT instanceof JSplitPane) return;

    PANEL.removeAll();

    if (value) {
      JSplitPane divider =
          new JSplitPane(
              JSplitPane.VERTICAL_SPLIT,
              LIBRARY_MEDIATOR.getComponent(),
              GUIMediator.getPlayList().getComponent());
      divider.setOneTouchExpandable(true);
      new DividerLocationSettingUpdater(
          divider, UISettings.UI_LIBRARY_PLAY_LIST_TAB_DIVIDER_LOCATION);
      COMPONENT = divider;
    } else COMPONENT = LIBRARY_MEDIATOR.getComponent();

    PANEL.add(COMPONENT, BorderLayout.CENTER);

    PANEL.invalidate();
    PANEL.validate();
  }
Пример #19
0
 @Override
 public void valueChanged(ListSelectionEvent e) {
   Object source = e.getSource();
   if (!e.getValueIsAdjusting() && source instanceof JList) {
     JList sourceList = (JList) source;
     // save last displayed component
     saveLastDialog();
     // load other panel if an index is selected
     int idx = sourceList.getSelectedIndex();
     if (idx >= 0) {
       AddonPanel panel = getPanel(idx);
       lastActivePanel = panel;
       container.removeAll();
       container.add(panel, BorderLayout.CENTER);
       // invalidate component, else it won't be redrawn
       container.invalidate();
       container.validate();
       container.repaint();
       // update icon in management panel
       dialog.setLogo(panel.getLogo());
     }
   }
 }
Пример #20
0
  public void updateResultTableTree(MongoResult mongoResult) {
    resultTableView =
        new JsonTreeTableView(
            JsonTreeModel.buildJsonTree(mongoResult), JsonTreeTableView.COLUMNS_FOR_READING);
    resultTableView.setName("resultTreeTable");

    resultTableView.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent mouseEvent) {
            if (mouseEvent.getClickCount() == 2 && MongoResultPanel.this.isSelectedNodeId()) {
              MongoResultPanel.this.editSelectedMongoDocument();
            }
          }
        });

    buildPopupMenu();

    resultTreePanel.invalidate();
    resultTreePanel.removeAll();
    resultTreePanel.add(new JBScrollPane(resultTableView));
    resultTreePanel.validate();
  }
Пример #21
0
  /**
   * Installes a demo bean.
   *
   * @param bean the demo bean
   */
  private void installBean(JComponent bean) {
    try {
      componentPanel.removeAll();
      componentPanel.add(bean);

      BeanInfo beanInfo =
          Introspector.getBeanInfo(bean.getClass(), bean.getClass().getSuperclass());
      PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();

      propertyPanel.removeAll();

      GridBagLayout gridbag = new GridBagLayout();
      GridBagConstraints c = new GridBagConstraints();
      c.fill = GridBagConstraints.BOTH;

      propertyPanel.setLayout(gridbag);

      int count = 0;

      String[] types =
          new String[] {
            "class java.util.Locale",
            "boolean",
            "int",
            "class java.awt.Color",
            "class java.util.Date",
            "class java.lang.String"
          };

      for (int t = 0; t < types.length; t++) {
        for (int i = 0; i < propertyDescriptors.length; i++) {
          if (propertyDescriptors[i].getWriteMethod() != null) {
            String type = propertyDescriptors[i].getPropertyType().toString();

            final PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
            final JComponent currentBean = bean;
            final Method readMethod = propertyDescriptor.getReadMethod();
            final Method writeMethod = propertyDescriptor.getWriteMethod();

            if (type.equals(types[t])
                && (((readMethod != null) && (writeMethod != null))
                    || ("class java.util.Locale".equals(type)))) {
              if ("boolean".equals(type)) {
                boolean isSelected = false;

                try {
                  Boolean booleanObj = ((Boolean) readMethod.invoke(bean, (Object[]) null));
                  isSelected = booleanObj.booleanValue();
                } catch (Exception e) {
                  e.printStackTrace();
                }

                final JCheckBox checkBox = new JCheckBox("", isSelected);
                checkBox.addActionListener(
                    new ActionListener() {
                      public void actionPerformed(ActionEvent event) {
                        try {
                          if (checkBox.isSelected()) {
                            writeMethod.invoke(currentBean, new Object[] {new Boolean(true)});
                          } else {
                            writeMethod.invoke(currentBean, new Object[] {new Boolean(false)});
                          }
                        } catch (Exception e) {
                          e.printStackTrace();
                        }
                      }
                    });
                addProperty(propertyDescriptors[i], checkBox, gridbag);
                count += 1;
              } else if ("int".equals(type)) {
                JSpinField spinField = new JSpinField();
                spinField.addPropertyChangeListener(
                    new PropertyChangeListener() {
                      public void propertyChange(PropertyChangeEvent evt) {
                        try {
                          if (evt.getPropertyName().equals("value")) {
                            writeMethod.invoke(currentBean, new Object[] {evt.getNewValue()});
                          }
                        } catch (Exception e) {
                        }
                      }
                    });

                try {
                  Integer integerObj = ((Integer) readMethod.invoke(bean, (Object[]) null));
                  spinField.setValue(integerObj.intValue());
                } catch (Exception e) {
                  e.printStackTrace();
                }

                addProperty(propertyDescriptors[i], spinField, gridbag);
                count += 1;
              } else if ("class java.lang.String".equals(type)) {
                String string = "";

                try {
                  string = ((String) readMethod.invoke(bean, (Object[]) null));
                } catch (Exception e) {
                  e.printStackTrace();
                }

                JTextField textField = new JTextField(string);
                ActionListener actionListener =
                    new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                        try {
                          writeMethod.invoke(currentBean, new Object[] {e.getActionCommand()});
                        } catch (Exception ex) {
                        }
                      }
                    };

                textField.addActionListener(actionListener);

                addProperty(propertyDescriptors[i], textField, gridbag);
                count += 1;
              } else if ("class java.util.Locale".equals(type)) {
                JLocaleChooser localeChooser = new JLocaleChooser(bean);
                localeChooser.setPreferredSize(
                    new Dimension(200, localeChooser.getPreferredSize().height));
                addProperty(propertyDescriptors[i], localeChooser, gridbag);
                count += 1;
              } else if ("class java.util.Date".equals(type)) {
                Date date = null;

                try {
                  date = ((Date) readMethod.invoke(bean, (Object[]) null));
                } catch (Exception e) {
                  e.printStackTrace();
                }

                JDateChooser dateChooser = new JDateChooser(date);

                dateChooser.addPropertyChangeListener(
                    new PropertyChangeListener() {
                      public void propertyChange(PropertyChangeEvent evt) {
                        try {
                          if (evt.getPropertyName().equals("date")) {
                            writeMethod.invoke(currentBean, new Object[] {evt.getNewValue()});
                          }
                        } catch (Exception e) {
                        }
                      }
                    });

                addProperty(propertyDescriptors[i], dateChooser, gridbag);
                count += 1;
              } else if ("class java.awt.Color".equals(type)) {
                final JButton button = new JButton();

                try {
                  final Color colorObj = ((Color) readMethod.invoke(bean, (Object[]) null));
                  button.setText("...");
                  button.setBackground(colorObj);

                  ActionListener actionListener =
                      new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                          Color newColor =
                              JColorChooser.showDialog(
                                  JCalendarDemo.this, "Choose Color", colorObj);
                          button.setBackground(newColor);

                          try {
                            writeMethod.invoke(currentBean, new Object[] {newColor});
                          } catch (Exception e1) {
                            e1.printStackTrace();
                          }
                        }
                      };

                  button.addActionListener(actionListener);
                } catch (Exception e) {
                  e.printStackTrace();
                }

                addProperty(propertyDescriptors[i], button, gridbag);
                count += 1;
              }
            }
          }
        }
      }

      URL iconURL = bean.getClass().getResource("images/" + bean.getName() + "Color16.gif");
      ImageIcon icon = new ImageIcon(iconURL);

      componentTitlePanel.setTitle(bean.getName(), icon);
      bean.invalidate();
      propertyPanel.invalidate();
      componentPanel.invalidate();
      componentPanel.repaint();
    } catch (IntrospectionException e) {
      e.printStackTrace();
    }
  }
Пример #22
0
  /** _more_ */
  protected void createChart() {

    if (madeChart) {
      return;
    }
    madeChart = true;
    final JCheckBox chartDiffCbx = new JCheckBox("Use Difference", chartDifference);
    chartDiffCbx.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            chartDifference = chartDiffCbx.isSelected();
            updateChart();
          }
        });

    chartTimeBox = new JList();
    chartTimeBox.setVisibleRowCount(3);
    chartTimeBox.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    chartTimeBox.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            if (ignoreChartTimeChanges) {
              return;
            }

            updateChart();
          }
        });

    List<StormParam> params = getStormTrackParams();

    Insets inset = new Insets(3, 7, 7, 0);
    List chartComps = new ArrayList();

    List<Way> ways = Misc.sort(stormDisplayState.getTrackCollection().getWayList());
    List wayComps = new ArrayList();
    for (Way way : ways) {
      final Way theWay = way;
      if (way.isObservation() && !chartWays.contains(way)) {
        chartWays.add(way);
      }
      final JCheckBox cbx = new JCheckBox(way.toString(), chartWays.contains(theWay));
      cbx.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              if (cbx.isSelected()) {
                addChartWay(theWay);
              } else {
                removeChartWay(theWay);
              }
            }
          });
      if (!way.isObservation()) {
        wayComps.add(cbx);
      } else {
        wayComps.add(0, cbx);
      }
    }

    chartComps.add(new JLabel(stormDisplayState.getStormTrackControl().getWaysName() + ":"));
    JComponent chartWayComp = GuiUtils.vbox(wayComps);
    if (wayComps.size() > 6) {
      chartWayComp = makeScroller(chartWayComp, 100, 150);
    }
    chartComps.add(GuiUtils.inset(chartWayComp, inset));
    chartComps.add(GuiUtils.lLabel((isHourly() ? "Forecast Hour:" : "Forecast Time:")));
    JScrollPane sp = new JScrollPane(chartTimeBox);
    chartComps.add(GuiUtils.inset(sp, inset));

    List paramComps = new ArrayList();
    for (StormParam param : params) {
      //   if (param.getIsChartParam() == false) {
      //       continue;
      //   }
      final StormParam theParam = param;
      boolean useChartParam = chartParams.contains(theParam);
      final JCheckBox cbx = new JCheckBox(param.toString(), useChartParam);
      cbx.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              if (cbx.isSelected()) {
                addChartParam(theParam);
              } else {
                removeChartParam(theParam);
              }
            }
          });
      paramComps.add(cbx);
    }
    chartComps.add(new JLabel("Parameters:"));
    JComponent paramComp = GuiUtils.vbox(paramComps);
    if (paramComps.size() > 6) {
      paramComp = makeScroller(paramComp, 100, 150);
    }
    chartComps.add(GuiUtils.inset(paramComp, inset));
    chartComps.add(chartDiffCbx);

    JButton removeBtn = GuiUtils.makeButton("Remove Chart", this, "removeChart");
    chartComps.add(GuiUtils.filler(5, 10));
    chartComps.add(removeBtn);

    //        JComponent top = GuiUtils.left(GuiUtils.hbox(
    //                                                     GuiUtils.label("Forecast Time: ",
    // chartTimeBox),
    //                                                     chartDiffCbx));
    //        top = GuiUtils.inset(top,5);
    //        chartTop.add(BorderLayout.NORTH, top);
    JComponent left = GuiUtils.doLayout(chartComps, 1, GuiUtils.WT_N, new double[] {0, 1, 0, 1, 0});
    chartLeft.add(BorderLayout.CENTER, GuiUtils.inset(left, 5));

    chartLeft.invalidate();
    chartLeft.validate();
    chartLeft.repaint();
  }
Пример #23
0
  public void restartCanvas() {
    canvasCover.invalidate();
    canvasCover.remove(canvas);
    canvas = new Canvas();
    shapeList = new ArrayList<Shapes>();
    lineList = new ArrayList<Line[]>();
    connectorList = new ArrayList<Connector>();
    selectedObject = null;
    changesMade = 0;
    title.setText("Untitled");

    canvas.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            int x = oldX = e.getX();
            int y = oldY = e.getY();
            if (shapePressed == SQUARE) {
              changesMade++;
              if (changesMade == 1) {
                title.setText("* " + title.getText());
              }

              canvas.doDraw(x, y);
            }
          }

          public void mouseReleased(MouseEvent e) {
            canvas.removeDrags();
            if (shapePressed == SQUARE) {
              canvas.doDraw(e.getX(), e.getY());
            }
            canSnap = true;
          }
        });

    canvas.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            xCord = e.getX();
            yCord = e.getY();
            coordinates.setText("Coordinates: (" + xCord + ", " + yCord + ")");
            if (shapePressed == SQUARE) {
              if (canSnap) {
                final int x = e.getX();
                final int y = e.getY();
                Thread newThread =
                    new Thread() {
                      public void run() {
                        canvas.doDraw(x, y);
                      }
                    };
                newThread.start();
                try {
                  newThread.join();
                } catch (InterruptedException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
              }
            }
          }

          @Override
          public void mouseMoved(MouseEvent e) {
            xCord = e.getX();
            yCord = e.getY();
            coordinates.setText("Coordinates: (" + xCord + ", " + yCord + ")");
          }
        });
    canvasCover.add(canvas);
    canvasCover.validate();
  }
Пример #24
0
 /** Remove the topic button when it out of from persistence */
 public void removeButton(String name) {
   JButton button = dynamicButtons.remove(name);
   contentPane.remove(button);
   contentPane.invalidate();
   contentPane.repaint();
 }
Пример #25
0
 @Override
 public void invalidate() {
   cells.clear();
   selectedCell = null;
   super.invalidate();
 }
Пример #26
0
 private void layoutPlayerPanel(final SetupPanel parent) {
   final GameData data = m_gameSelectorModel.getGameData();
   m_localPlayerPanel.removeAll();
   m_playerTypes.clear();
   m_localPlayerPanel.setLayout(new GridBagLayout());
   if (data == null) {
     m_localPlayerPanel.add(new JLabel("No game selected!"));
     return;
   }
   final Collection<String> disableable = data.getPlayerList().getPlayersThatMayBeDisabled();
   final HashMap<String, Boolean> playersEnablementListing =
       data.getPlayerList().getPlayersEnabledListing();
   final Map<String, String> reloadSelections = PlayerID.currentPlayers(data);
   final String[] playerTypes = data.getGameLoader().getServerPlayerTypes();
   final String[] playerNames = data.getPlayerList().getNames();
   // if the xml was created correctly, this list will be in turn order. we want to keep it that
   // way.
   int gridx = 0;
   int gridy = 0;
   if (!disableable.isEmpty() || playersEnablementListing.containsValue(Boolean.FALSE)) {
     final JLabel enableLabel = new JLabel("Use");
     enableLabel.setForeground(Color.black);
     m_localPlayerPanel.add(
         enableLabel,
         new GridBagConstraints(
             gridx++,
             gridy,
             1,
             1,
             0,
             0,
             GridBagConstraints.WEST,
             GridBagConstraints.NONE,
             new Insets(0, 5, 5, 0),
             0,
             0));
   }
   final JLabel nameLabel = new JLabel("Name");
   nameLabel.setForeground(Color.black);
   m_localPlayerPanel.add(
       nameLabel,
       new GridBagConstraints(
           gridx++,
           gridy,
           1,
           1,
           0,
           0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 5, 5, 0),
           0,
           0));
   final JLabel typeLabel = new JLabel("Type");
   typeLabel.setForeground(Color.black);
   m_localPlayerPanel.add(
       typeLabel,
       new GridBagConstraints(
           gridx++,
           gridy,
           1,
           1,
           0,
           0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 5, 5, 0),
           0,
           0));
   final JLabel allianceLabel = new JLabel("Alliance");
   allianceLabel.setForeground(Color.black);
   m_localPlayerPanel.add(
       allianceLabel,
       new GridBagConstraints(
           gridx++,
           gridy,
           1,
           1,
           0,
           0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 7, 5, 5),
           0,
           0));
   for (final String playerName : playerNames) {
     final PBEMLocalPlayerComboBoxSelector selector =
         new PBEMLocalPlayerComboBoxSelector(
             playerName,
             reloadSelections,
             disableable,
             playersEnablementListing,
             data.getAllianceTracker()
                 .getAlliancesPlayerIsIn(data.getPlayerList().getPlayerID(playerName)),
             playerTypes,
             parent);
     m_playerTypes.add(selector);
     selector.layout(++gridy, m_localPlayerPanel);
   }
   m_localPlayerPanel.validate();
   m_localPlayerPanel.invalidate();
 }
Пример #27
0
 /**
  * This adds the specified component to the setup panel. It is added below the last 'default'
  * item. You can only add 1 component here, so if you need to add multiple things, you'll have to
  * handle adding that to yourself to the one component.
  *
  * @param component the component to add.
  */
 public void setCustomPanel(JComponent component) {
   customPanelPlaceHolder.add(component, BorderLayout.CENTER);
   customPanelPlaceHolder.invalidate();
   mainPanel.validate();
 }
Пример #28
0
 @Override
 public void invalidate() {
   super.invalidate();
 }