Example #1
0
  /** If there's anything to print, initiate a print job */
  public synchronized void actionPerformed(ActionEvent ae) {
    if (isPrintUnderway) {
      out("ignoring [" + ae.getActionCommand() + "]; print already underway.");
      return;
    }
    LWMap map = VUE.getActiveMap();
    Rectangle2D bounds = map.getBounds();
    if (bounds.isEmpty()) {
      out("nothing to print in " + map);
      return;
    }
    boolean viewerPrint = false;
    if (ae.getActionCommand() != null && ae.getActionCommand().indexOf("Visible") >= 0)
      viewerPrint = true;

    // if any tool windows open in W2K/1.4.2 when start this thread,
    // the print dialog get's obscured!

    isPrintUnderway = true;
    setEnabled(false);
    try {
      new PrintJob(VUE.getActiveViewer(), viewerPrint).start();
      //             if (DEBUG.Enabled)
      //                 new PrintJob(VUE.getActiveViewer(), viewerPrint).start();
      //             else
      //                 new PrintJob(VUE.getActiveViewer(), viewerPrint).runPrint();
    } catch (Throwable t) {
      out("exception creating or running PrintJob: " + t);
      t.printStackTrace();
      isPrintUnderway = false;
      setEnabled(true);
    }
  }
Example #2
0
 /** Creates a new instance of NodeFilterEditor */
 public NodeFilterEditor(NodeFilter nodeFilter, boolean editable) {
   this.nodeFilter = nodeFilter;
   tufts.vue.LWMap map = tufts.vue.VUE.getActiveMap();
   if (map != null) map.getMapFilterModel().addListener(this);
   tufts.vue.VUE.addActiveListener(tufts.vue.LWMap.class, this);
   questionLabel.setToolTipText(NodeFilterEditor.NODE_FILTER_INFO);
   setNodeFilterPanel();
 }
Example #3
0
    public AddElementDialog(MapFilterModel model) {
      super(
          tufts.vue.VUE.getDialogParentAsFrame(),
          VueResources.getString("dialog.addkey.title"),
          true);
      this.model = model;
      allTypes = (Vector) TypeFactory.getAllTypes();
      keyLabel = new JLabel(VueResources.getString("nodefilter.field.label"));
      typeLabel = new JLabel(VueResources.getString("nodefilter.type.label"));
      keyEditor = new JTextField();
      typeEditor = new JComboBox(allTypes);
      keyEditor.setPreferredSize(new Dimension(80, 20));
      JPanel keyPanel = new JPanel();
      keyPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      keyPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
      keyPanel.add(keyLabel);
      keyPanel.add(keyEditor);

      JPanel typePanel = new JPanel();
      typePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      typePanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
      typePanel.add(typeLabel);
      typePanel.add(typeEditor);

      // SOUTH: southPanel(cancelButton, okButton)

      JButton okButton = new JButton(VueResources.getString("button.ok.label"));
      okButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              updateModelAndNotify();
              setVisible(false);
            }
          });

      JButton cancelButton = new JButton(VueResources.getString("button.cancel.lable"));
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              setVisible(false);
            }
          });

      JPanel southPanel = new JPanel();
      southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(okButton);
      southPanel.add(cancelButton);
      BoxLayout layout = new BoxLayout(getContentPane(), BoxLayout.Y_AXIS);

      getContentPane().setLayout(layout);
      getContentPane().add(keyPanel);
      getContentPane().add(typePanel);
      getContentPane().add(southPanel);
      pack();
      setLocation(NodeFilterEditor.this.getLocationOnScreen());
      setVisible(true);
    }
Example #4
0
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   TableModel tableModel = table.getModel();
   if (tableModel instanceof NodeFilter) {
     editor =
         new JComboBox((Vector) tufts.vue.VUE.getActiveMap().getMapFilterModel().getKeyVector());
     return editor;
   }
   return (new JComboBox()); // if no editor present
 }
Example #5
0
  /*@Override*/ public void paintIcon(Component c, Graphics g, int x, int y) {
    final boolean expandToFit = (mWidth < 1);

    if (DEBUG.IMAGE && DEBUG.META)
      out(
          "paintIcon; onto="
              + GUI.name(c)
              + " painter="
              + GUI.name(mPainter)
              + "@"
              + Integer.toHexString((mPainter.hashCode())));

    if (mPainter == null) {
      // note this means repaint updates would stop in a new parent,
      // tho assuming it's loaded by then, regular paints would work fine.
      mPainter = c;
    }

    if (DrawBorder && !expandToFit) {
      g.setColor(Color.gray);
      g.drawRect(x, y, mWidth - 1, mHeight - 1);
    }

    if (mImage == null) {

      if (!isLoading /*&& mPreviewData != null*/) {
        synchronized (this) {
          if (!isLoading /*&& mPreviewData != null*/)
            VUE.invokeAfterAWT(ResourceIcon.this); // load the preview
        }
      }
      g.setColor(Color.gray);
      g.drawRect(x, y, mWidth - 1, mHeight - 1);
      return;
    }

    int fitWidth, fitHeight;
    final Dimension maxImageSize;

    if (expandToFit) {
      // fill the given component
      fitWidth = c.getWidth();
      fitHeight = c.getHeight();
      maxImageSize = c.getSize();
    } else {
      // paint at our fixed size
      fitWidth = mWidth;
      fitHeight = mHeight;

      if (DrawBorder)
        maxImageSize = new Dimension(fitWidth - BorderSpace * 2, fitHeight - BorderSpace * 2);
      else maxImageSize = new Dimension(fitWidth, fitHeight);

      if (DEBUG.IMAGE && DEBUG.META) out("paintIcon; into " + GUI.name(maxImageSize));
    }

    double zoomFit;
    if (mImage == NoImage && expandToFit) {
      zoomFit = 1;
    } else {
      Rectangle2D imageBounds;
      if (CropToSquare) {
        // square off image, then fit in icon (todo: better; crop to icon)
        int smallestAxis = mImageWidth > mImageHeight ? mImageHeight : mImageWidth;
        imageBounds = new Rectangle2D.Float(0, 0, smallestAxis, smallestAxis);
      } else {
        // fit entire image in icon
        imageBounds = new Rectangle2D.Float(0, 0, mImageWidth, mImageHeight);
      }
      zoomFit = ZoomTool.computeZoomFit(maxImageSize, 0, imageBounds, null, false);
      if (zoomFit > MaxZoom) zoomFit = MaxZoom;
    }

    final int drawW = (int) (mImageWidth * zoomFit + 0.5);
    final int drawH = (int) (mImageHeight * zoomFit + 0.5);

    int xoff = x;
    int yoff = y;

    // center if drawable area is bigger than image
    if (drawW != fitWidth) xoff += (fitWidth - drawW) / 2;
    if (drawH != fitHeight) yoff += (fitHeight - drawH) / 2;

    Shape oldClip = null;
    if (CropToSquare && !expandToFit) {
      oldClip = g.getClip();
      g.clipRect(x, y, mWidth, mHeight);
    }

    if (DEBUG.IMAGE && DEBUG.META)
      out("paintIcon; " + Util.tag(mImage) + " as " + drawW + "x" + drawH);
    g.drawImage(mImage, xoff, yoff, drawW, drawH, null);

    if (DEBUG.BOXES) {
      g.setColor(Color.green);
      ((Graphics2D) g)
          .setComposite(
              java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.SRC_OVER, 0.2f));
      g.drawRect(x, y, mWidth - 1, mHeight - 1);
      ((Graphics2D) g).setComposite(java.awt.AlphaComposite.SrcOver);
    }

    if (CropToSquare && !expandToFit) g.setClip(oldClip);
  }
Example #6
0
    public AddDialog(NodeFilter model) {
      super(
          tufts.vue.VUE.getDialogParentAsFrame(),
          VueResources.getString("dialog.addkey.title"),
          true);
      this.model = model;
      allTypes = (Vector) TypeFactory.getAllTypes();
      keyLabel = new JLabel(VueResources.getString("button.key.label"));
      typeLabel = new JLabel(VueResources.getString("nodefilter.type.label"));
      operatorLabel = new JLabel(VueResources.getString("nodefilter.operator.label"));
      valueLabel = new JLabel(VueResources.getString("nodefilter.value.label"));
      keyEditor = new JComboBox(tufts.vue.VUE.getActiveMap().getMapFilterModel().getKeyVector());

      operatorEditor = new JComboBox();
      valueEditor = new JTextField();
      typeEditor = new JTextField();
      typeEditor.setEditable(false);

      keyEditor.setPreferredSize(new Dimension(80, 20));

      GridBagLayout gridbag = new GridBagLayout();
      GridBagConstraints c = new GridBagConstraints();
      c.insets = new Insets(2, 2, 2, 2);
      JPanel panel = new JPanel();
      panel.setLayout(gridbag);

      c.anchor = GridBagConstraints.EAST;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(keyLabel, c);
      panel.add(keyLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      gridbag.setConstraints(keyEditor, c);
      panel.add(keyEditor);

      c.anchor = GridBagConstraints.EAST;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(operatorLabel, c);
      panel.add(operatorLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      gridbag.setConstraints(operatorEditor, c);
      panel.add(operatorEditor);

      c.anchor = GridBagConstraints.EAST;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(valueLabel, c);
      panel.add(valueLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.fill = GridBagConstraints.HORIZONTAL;
      gridbag.setConstraints(valueEditor, c);
      panel.add(valueEditor);

      c.anchor = GridBagConstraints.EAST;
      c.fill = GridBagConstraints.NONE;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(typeLabel, c);
      panel.add(typeLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.fill = GridBagConstraints.HORIZONTAL;
      gridbag.setConstraints(typeEditor, c);
      panel.add(typeEditor);

      // SOUTH: southPanel(cancelButton, okButton)

      JButton okButton = new JButton(VueResources.getString("button.ok.label"));
      okButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              updateModelAndNotify();
              setVisible(false);
            }
          });

      JButton cancelButton = new JButton(VueResources.getString("button.cancel.lable"));
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              setVisible(false);
            }
          });

      JPanel southPanel = new JPanel();
      southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(okButton);
      southPanel.add(cancelButton);

      c.gridwidth = GridBagConstraints.REMAINDER;
      gridbag.setConstraints(southPanel, c);
      panel.add(southPanel);

      getContentPane().setLayout(new BorderLayout());
      getContentPane().add(panel, BorderLayout.CENTER);

      pack();
      setLocation(500, 300);
      setVisible(true);
    }
Example #7
0
  private void setNodeFilterPanel() {
    lWMap = tufts.vue.VUE.getActiveMap();
    addButton.setToolTipText(VueResources.getString("nodefilter.addfilter.tooltip"));
    deleteButton.setToolTipText(VueResources.getString("nodefilter.deletefilter.tooltip"));
    elementsModel = new ElementComboBoxModel();
    elementsModel.setElements(lWMap.getMapFilterModel().getKeyVector());
    elements = new JComboBox(elementsModel);
    Font f = elements.getFont();
    Font menuFont = new Font(f.getFontName(), f.getStyle(), f.getSize() - 2);
    elements.setFont(menuFont);
    // elements.setPreferredSize(new Dimension(150,20));
    /// this is not user friendly may want to fix later.
    /**
     * elements.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) {
     * if(e.getStateChange() == ItemEvent.SELECTED) { if(e.getItem().toString() == ADD_ELEMENT) { }
     * else if(e.getItem() instanceof Key) { Statement stmt = new Statement();
     * stmt.setKey((Key)e.getItem()); nodeFilter.addStatement(stmt);
     * nodeFilter.fireTableDataChanged(); } else { System.out.println("Not Supported"); } } } });
     */
    nodeFilterTable = new JTable(nodeFilter);
    nodeFilterTable.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent e) {
            if (nodeFilterTable.isEditing()) {
              nodeFilterTable
                  .getCellEditor(
                      nodeFilterTable.getEditingRow(), nodeFilterTable.getEditingColumn())
                  .stopCellEditing();
            }
            nodeFilterTable.removeEditor();
          }

          public void focusGained(FocusEvent e) {}
        });
    nodeFilterTable.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (nodeFilterTable.getSelectedRow() == (nodeFilterTable.getRowCount() - 1)
                && e.getKeyCode() == e.VK_ENTER) {
              addButtonListener.addStatement();
            }
          }
        });

    nodeFilterTable.setPreferredScrollableViewportSize(new Dimension(240, 100));
    JScrollPane nodeFilterScrollPane = new JScrollPane(nodeFilterTable);
    nodeFilterScrollPane.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel nodeFilterPanel = new JPanel();
    nodeFilterPanel.setLayout(new BorderLayout());
    nodeFilterPanel.add(nodeFilterScrollPane, BorderLayout.CENTER);
    addButtonListener = new AddButtonListener(nodeFilter);
    addButton.addActionListener(addButtonListener);
    deleteButton.setEnabled(false);
    sListener = new NodeFilterSelectionListener(deleteButton, -1);
    nodeFilterTable.getSelectionModel().addListSelectionListener(sListener);
    deleteButtonListener = new DeleteButtonListener(nodeFilterTable, sListener);
    deleteButton.addActionListener(deleteButtonListener);

    // keyEditor = new KeyCellEditor();
    // nodeFilterTable.getColumnModel().getColumn(NodeFilter.KEY_COL).setCellEditor(keyEditor);
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS));
    JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 0));
    // bottomPanel.setBorder(BorderFactory.createEmptyBorder(3,6,3,6));
    bottomPanel.add(elementLabel);
    bottomPanel.add(elements);
    bottomPanel.add(addButton);
    bottomPanel.add(deleteButton);
    bottomPanel.add(questionLabel);
    // innerPanel.add(labelPanel);
    innerPanel.add(bottomPanel);
    innerPanel.add(nodeFilterPanel);
    setLayout(new BorderLayout());
    add(innerPanel, BorderLayout.CENTER);

    validate();
  }