Esempio n. 1
0
  @Override
  public Component prepareRenderer(
      final TableCellRenderer renderer, final int row, final int column) {
    Component component = super.prepareRenderer(renderer, row, column);
    boolean isSelected = isCellSelected(row, column);
    Value value = tableModel.getElementAt(row);
    String columnName =
        (String) this.getTableHeader().getColumnModel().getColumn(column).getHeaderValue();
    Object object = getValueAt(row, column);
    boolean string;
    if (object instanceof String) {
      string = true;
    } else {
      string = false;
    }

    // UGrand Total
    if (value.isGrandTotal()) {
      if (!isSelected) {
        component.setBackground(new Color(230, 230, 230));
      } else {
        component.setBackground(this.getSelectionBackground().darker());
      }
      return component;
    }
    // Best Asset: none
    if (string
        && TabsValues.get().none().equals(value.getBestAssetName())
        && columnName.equals(ValueTableFormat.BEST_ASSET_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    // Best Module: none
    if (string
        && TabsValues.get().none().equals(value.getBestModuleName())
        && columnName.equals(ValueTableFormat.BEST_MODULE_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    // Best Ship (Fitted): none
    if (string
        && TabsValues.get().none().equals(value.getBestShipFittedName())
        && columnName.equals(ValueTableFormat.BEST_SHIP_FITTED_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    // Best Ship: none
    if (string
        && TabsValues.get().none().equals(value.getBestShipName())
        && columnName.equals(ValueTableFormat.BEST_SHIP_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    return component;
  }
Esempio n. 2
0
  private static Pair<Image, Point> createDragImage(
      final Tree tree, final Component c, Point dragOrigin, boolean adjustToPathUnderDragOrigin) {
    if (c instanceof JComponent) {
      ((JComponent) c).setOpaque(true);
    }

    c.setForeground(tree.getForeground());
    c.setBackground(tree.getBackground());
    c.setFont(tree.getFont());
    c.setSize(c.getPreferredSize());
    final BufferedImage image =
        new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D) image.getGraphics();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
    c.paint(g2);
    g2.dispose();

    Point point = new Point(-image.getWidth(null) / 2, -image.getHeight(null) / 2);

    if (adjustToPathUnderDragOrigin) {
      TreePath path = tree.getPathForLocation(dragOrigin.x, dragOrigin.y);
      if (path != null) {
        Rectangle bounds = tree.getPathBounds(path);
        point = new Point(bounds.x - dragOrigin.x, bounds.y - dragOrigin.y);
      }
    }

    return new Pair<Image, Point>(image, point);
  }
 private static void drawSelection(JTree tree, Graphics g, final int width) {
   int y = 0;
   final int[] rows = tree.getSelectionRows();
   final int height = tree.getRowHeight();
   for (int row : rows) {
     final TreeCellRenderer renderer = tree.getCellRenderer();
     final Object value = tree.getPathForRow(row).getLastPathComponent();
     if (value == null) continue;
     final Component component =
         renderer.getTreeCellRendererComponent(tree, value, false, false, false, row, false);
     if (component.getFont() == null) {
       component.setFont(tree.getFont());
     }
     g.translate(0, y);
     component.setBounds(0, 0, width, height);
     boolean wasOpaque = false;
     if (component instanceof JComponent) {
       final JComponent j = (JComponent) component;
       if (j.isOpaque()) wasOpaque = true;
       j.setOpaque(false);
     }
     component.paint(g);
     if (wasOpaque) {
       ((JComponent) component).setOpaque(true);
     }
     y += height;
     g.translate(0, -y);
   }
 }
Esempio n. 4
0
 /**
  * Sets the font for a component and all components contained within it.
  *
  * @param c the parent component of the component subtree to set
  * @param font the font to set
  */
 public static void setFont(Component c, Font font) {
   c.setFont(font);
   if (c instanceof Container) {
     Container con = (Container) c;
     for (int i = 0; i < con.getComponentCount(); ++i) setFont(con.getComponent(i), font);
   }
 }
Esempio n. 5
0
    public Component getTableCellRendererComponent(
        JTable t, Object o, boolean is, boolean hf, int r, int c) {
      Component cell = super.getTableCellRendererComponent(t, o, is, hf, r, c);

      EventResultModel m = (EventResultModel) t.getModel();
      String s = (String) m.getValueAt(r, 1);
      if (s.equals(match)) {
        cell.setFont(bold);
        cell.setBackground(mygray);
      } else {
        cell.setFont(regular);
        cell.setBackground(Color.WHITE);
      }

      return cell;
    }
Esempio n. 6
0
 public static void bumpUpFontSize(Component widget, int bumps) {
   if (!UserPreferences.readLocalePref()
       .equals("ko")) { // HACK!!!  refector with variable localeSupportsBold
     Font f = widget.getFont();
     widget.setFont(new Font(f.getFamily(), f.getStyle(), f.getSize() + bumps));
   }
 }
Esempio n. 7
0
  /** Empty the interface. */
  public void resetInterface() {
    // Empty tree objects
    this.treeNodeModels.clear();
    this.consoles.clear();

    /*
     * TODO : clear properly paused processes remaining when another new
     * injection is run.
     */
    // GUIMediator.model().suspendables.clear();

    MediatorGUI.bottomPanel().listHTTPHeader.clear();

    // Tree model for refreshing the tree
    DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGUI.databaseTree().getModel();
    // The tree root
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();

    // Delete tabs
    MediatorGUI.right().removeAll();
    // Remove tree nodes
    root.removeAllChildren();
    // Refresh the root
    treeModel.nodeChanged(root);
    // Refresh the tree
    treeModel.reload();
    MediatorGUI.databaseTree().setRootVisible(true);

    // Empty infos tabs
    MediatorGUI.bottomPanel().chunkTab.setText("");
    MediatorGUI.bottomPanel().binaryTab.setText("");
    ((DefaultTableModel) MediatorGUI.bottomPanel().networkTable.getModel()).setRowCount(0);
    MediatorGUI.bottomPanel().javaTab.getProxy().setText("");

    MediatorGUI.bottomPanel().networkTabHeader.setText("");
    MediatorGUI.bottomPanel().networkTabParam.setText("");
    MediatorGUI.bottomPanel().networkTabResponse.setText("");
    MediatorGUI.bottomPanel().networkTabTiming.setText("");
    MediatorGUI.bottomPanel().networkTabSource.setText("");
    MediatorGUI.bottomPanel().networkTabPreview.setText("");

    for (int i = 0; i < MediatorGUI.bottom().getTabCount(); i++) {
      Component tabComponent = MediatorGUI.bottom().getTabComponentAt(i);
      if (tabComponent != null) {
        tabComponent.setFont(tabComponent.getFont().deriveFont(Font.PLAIN));
      }
    }

    MediatorGUI.left().fileManager.setButtonEnable(false);
    MediatorGUI.left().shellManager.setButtonEnable(false);
    MediatorGUI.left().sqlShellManager.setButtonEnable(false);

    // Default status info
    MediatorGUI.status().reset();

    MediatorGUI.left().fileManager.changePrivilegeIcon(HelperGUI.SQUARE_GREY);
    MediatorGUI.left().shellManager.changePrivilegeIcon(HelperGUI.SQUARE_GREY);
    MediatorGUI.left().sqlShellManager.changePrivilegeIcon(HelperGUI.SQUARE_GREY);
    MediatorGUI.left().uploadManager.changePrivilegeIcon(HelperGUI.SQUARE_GREY);
  }
Esempio n. 8
0
 public static void makeEmphasized(Component widget) {
   // Set to bold amd add color
   Font font = widget.getFont();
   if (!UserPreferences.readLocalePref()
       .equals("ko")) // HACK!!!  refector with variable localeSupportsBold
   widget.setFont(new Font(font.getFamily(), Font.BOLD, font.getSize()));
   widget.setForeground(UIProperties.emphasisColor);
 }
Esempio n. 9
0
  /**
   * Sets the font for an entire component hierarchy to the specified font.
   *
   * @param c the starting component
   * @param font the font to set
   */
  public static void setComponentTreeFont(Component c, Font font) {
    c.setFont(font);

    Component[] children = getChildren(c);

    if (children != null) {
      for (int i = 0; i < children.length; i++) {
        setComponentTreeFont(children[i], font);
      }
    }
  }
  public void setKeyboardFont(Font f) {
    f = f.deriveFont(fontSize);

    JPanel p = (JPanel) getContentPane();
    for (int i = 0; i < p.getComponentCount(); i++) {
      Component c = p.getComponent(i);
      c.setFont(f);
    }

    pack();
  }
  @Override
  public void incrementFont(float incr) {
    Deque<Component> components = new ArrayDeque<>();
    components.addAll(Arrays.asList(getComponents()));
    Component c = null;
    while (null != (c = components.poll())) {
      Font f = c.getFont();
      c.setFont(f.deriveFont(f.getSize2D() + incr));

      if (c instanceof Container) {
        components.addAll(Arrays.asList(Container.class.cast(c).getComponents()));
      }
    }
  }
  private void updateFontSizeForPanel(JPanel panel) {
    int font_size = (int) (panel.getWidth() * ENTRY_FONT_SIZE);
    if (font_size > MAX_ENTRY_FONT_SIZE) {
      font_size = MAX_ENTRY_FONT_SIZE;
    }

    JLabel temp = new JLabel();
    Font font = new Font(temp.getFont().getFontName(), Font.BOLD, font_size);

    for (Component comp : panel.getComponents()) {
      comp.setFont(font);
    }

    panel.revalidate();
  }
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Component component =
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    if (((ChapterForSubscriptionTableModel) table.getModel())
            .getChapter(table.convertRowIndexToModel(row))
            .getRead()
        == UNREAD) {
      component.setFont(component.getFont().deriveFont(Font.BOLD));
    }

    return component;
  }
  @Override
  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component returnComp = super.prepareRenderer(renderer, row, column);
    Color alternateColor = new Color(229, 255, 232);
    Color whiteColor = Color.WHITE;

    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment(JLabel.CENTER);
    this.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);

    if (!returnComp.getBackground().equals(getSelectionBackground())) {
      Color bg = (row % 2 == 0 ? alternateColor : whiteColor);
      returnComp.setBackground(bg);
    }
    returnComp.setFont(tableFont);
    return returnComp;
  }
 @Override
 public Component getListCellRendererComponent(
     JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   final MagicDeck deck = (MagicDeck) value;
   final Component c =
       super.getListCellRendererComponent(list, deck.getName(), index, isSelected, cellHasFocus);
   if (deck.isValid() == false) {
     if (invalidDeckFont == null) {
       final Map<TextAttribute, Object> attributes = new HashMap<>();
       attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
       invalidDeckFont = c.getFont().deriveFont(attributes);
     }
     c.setFont(invalidDeckFont);
     c.setForeground(isSelected ? list.getSelectionForeground() : Color.RED.darker());
   }
   return c;
 }
 public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) {
   ListCellRenderer renderer = comboBox.getRenderer();
   Component c;
   Dimension d;
   c =
       renderer.getListCellRendererComponent(
           listBox, comboBox.getSelectedItem(), -1, false, false);
   c.setFont(comboBox.getFont());
   if (comboBox.isEnabled()) {
     c.setForeground(comboBox.getForeground());
     c.setBackground(comboBox.getBackground());
   } else {
     c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
     c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
   }
   d = c.getPreferredSize();
   currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, d.height);
 }
Esempio n. 17
0
 /**
  * Adds a message consisting of one or more lines of text, which will be displayed using the
  * specified font and color.
  */
 public void addMessage(String text, Font font, Color color) {
   theLabel = null;
   if (text.indexOf('\n') >= 0) theLabel = new MultiLineLabel(text);
   else theLabel = new Label(text);
   // theLabel.addKeyListener(this);
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = getInsets(text.equals("") ? 0 : 10, 20, 0, 0);
   c.fill = GridBagConstraints.HORIZONTAL;
   grid.setConstraints(theLabel, c);
   if (font != null) theLabel.setFont(font);
   if (color != null) theLabel.setForeground(color);
   add(theLabel);
   c.fill = GridBagConstraints.NONE;
   y++;
 }
Esempio n. 18
0
  @Override
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {

    Component c =
        super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    c.setFont(MacFontUtils.ITUNES_FONT);
    c.setForeground(tree.getForeground());
    c.setBackground(tree.getBackground());
    setBackground(tree.getBackground());

    return c;
  }
Esempio n. 19
0
 public XFInputDialogField(
     String fieldCaption, String inputType, String parmID, XFInputDialog dialog) {
   super();
   parmID_ = parmID;
   if (!inputType.equals("ALPHA")
       && !inputType.equals("KANJI")
       && !inputType.equals("NUMERIC")
       && !inputType.equals("DATE")
       && !inputType.equals("LISTBOX")
       && !inputType.equals("CHECKBOX")) {
     inputType_ = "ALPHA";
   }
   inputType_ = inputType;
   dialog_ = dialog;
   jLabelField.setText(fieldCaption + " ");
   jLabelField.setFocusable(false);
   jLabelField.setHorizontalAlignment(SwingConstants.RIGHT);
   jLabelField.setVerticalAlignment(SwingConstants.TOP);
   jLabelField.setFont(new java.awt.Font("Dialog", 0, 14));
   metrics = jLabelField.getFontMetrics(new java.awt.Font("Dialog", 0, 14));
   jLabelField.setPreferredSize(new Dimension(120, XFUtility.FIELD_UNIT_HEIGHT));
   if (metrics.stringWidth(fieldCaption) > 120) {
     jLabelField.setFont(new java.awt.Font("Dialog", 0, 12));
     metrics = jLabelField.getFontMetrics(new java.awt.Font("Dialog", 0, 12));
     if (metrics.stringWidth(fieldCaption) > 120) {
       jLabelField.setFont(new java.awt.Font("Dialog", 0, 10));
     }
   }
   if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) {
     JTextField field = new JTextField();
     field.addFocusListener(new ComponentFocusListener());
     if (inputType_.equals("NUMERIC")) {
       field.setHorizontalAlignment(SwingConstants.RIGHT);
       field.setDocument(new LimitedDocument(this));
     }
     component = field;
   }
   if (inputType_.equals("DATE")) {
     XFDateField field = new XFDateField(dialog_.getSession());
     component = field;
   }
   if (inputType_.equals("LISTBOX")) {
     JComboBox field = new JComboBox();
     component = field;
   }
   if (inputType_.equals("CHECKBOX")) {
     JCheckBox field = new JCheckBox();
     component = field;
   }
   component.setFont(new java.awt.Font("Monospaced", 0, 14));
   metrics = component.getFontMetrics(new java.awt.Font("Monospaced", 0, 14));
   this.setOpaque(false);
   if (inputType_.equals("DATE")) {
     int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14);
     this.setBounds(
         this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT);
   } else {
     this.setBounds(this.getBounds().x, this.getBounds().y, 150, XFUtility.FIELD_UNIT_HEIGHT);
   }
   this.setLayout(new BorderLayout());
   this.add(jLabelField, BorderLayout.WEST);
   this.add(component, BorderLayout.CENTER);
 }
    @Override
    public Component getTableCellRendererComponent(
        JTable table1, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

      // Boolean value: show as checkbox
      boolean isBoolean = value instanceof Boolean;

      boolean isImage = value instanceof ImageIcon;

      Component comp = isBoolean ? cbTemp : (Component) this;

      if (isBoolean) comp = cbTemp;
      else if (isImage) comp = iTemp;
      else comp = this;

      int step = kernel.getConstructionStep();
      RowData rd = data.getRow(row);
      int index = rd.getGeo().getConstructionIndex();
      if (useColors)
        comp.setForeground(
            org.geogebra.desktop.awt.GColorD.getAwtColor(rd.getGeo().getAlgebraColor()));
      else comp.setForeground(Color.black);

      if (index == step) { // current construction step background color
        comp.setBackground(COLOR_STEP_HIGHLIGHT);
      } else if (index < step) {
        comp.setBackground(Color.white);
      } else {
        comp.setForeground(Color.gray);
        comp.setBackground(Color.white);
      }

      // set background color
      if (dragging) {
        if (index == dragIndex) { // drag & drop background color
          comp.setBackground(COLOR_DRAG_HIGHLIGHT);
        } else if (index == dropIndex) { // drag & drop background color
          comp.setBackground(COLOR_DROP_HIGHLIGHT);
        }
      }

      comp.setFont(table1.getFont());

      if (isBoolean) {
        cbTemp.setSelected(((Boolean) value).booleanValue());
        cbTemp.setEnabled(true);
        return cbTemp;
      }
      if (isImage) {
        /*
         * Scaling does not work yet. I wonder why. Image miniImage =
         * ((ImageIcon) value).getImage().getScaledInstance(16,16,0);
         * ImageIcon miniIcon = new ImageIcon();
         * miniIcon.setImage(miniImage); iTemp.setIcon((ImageIcon)
         * value); iTemp.setHorizontalAlignment(JLabel.CENTER);
         * iTemp.setMaximumSize(new Dimension(16,16)); return iTemp;
         */
        iTemp.setIcon((ImageIcon) value);
        return iTemp;
      }

      setText((value == null) ? "" : value.toString());
      return this;
    }
Esempio n. 21
0
 public void setFont(Font font) {
   super.setFont(font);
   repaint();
 }
Esempio n. 22
0
 public static void makeSmallBold(Component widget) {
   widget.setFont(
       new Font(widget.getFont().getFamily(), Font.BOLD, widget.getFont().getSize() - 1));
 }
Esempio n. 23
0
 public static void makeBold(Component widget) {
   if (!UserPreferences.readLocalePref()
       .equals("ko")) // HACK!!!  refector with variable localeSupportsBold
   widget.setFont(new Font(widget.getFont().getFamily(), Font.BOLD, widget.getFont().getSize()));
 }
 protected void applyFont(Component renderer, ComponentAdapter adapter) {
   Font font = getColumnFont(adapter.getColumnName(adapter.column));
   if (font != null) {
     renderer.setFont(font);
   }
 }
  public Component getTreeCellRendererComponent(
      JTree treeI,
      Object valueI,
      boolean selI,
      boolean expandedI,
      boolean leafI,
      int rowI,
      boolean hasFocusI) {

    ImageIcon icon = null;

    // Get the default renderer and then override its icon
    Component defaultComp =
        super.getTreeCellRendererComponent(treeI, valueI, selI, expandedI, leafI, rowI, hasFocusI);

    // Get the selected component
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) valueI;

    defaultComp.setFont(new Font("Dialog", Font.PLAIN, 12));

    Object userObject = node.getUserObject();

    if ((userObject == null) || (userObject instanceof AdminTreeUserObject) != true) {
      // JPW 02/14/2002: Display text in italic and don't display icon.
      defaultComp.setFont(new Font("Dialog", Font.ITALIC, 12));
      setIcon(null);
      return defaultComp;
    }

    Rmap storedRmap = ((AdminTreeUserObject) node.getUserObject()).getRmap();

    // Return the image corresponding to the type of Rmap

    // NOTE: Must test for instanceof Sink *before* testing for
    //       instanceof Source since Sink is a subclass of Source.

    int width = -1;
    int height = -1;
    int imageArray[] = null;

    if (storedRmap instanceof Controller) {
      width = controllerImageWidth;
      height = controllerImageHeight;
      imageArray = controllerImage;
    } else if (storedRmap instanceof PlugIn) {
      // JPW 09/19/2005: PlugIns have their own image to display
      /*
      width = sourceImageWidth;
      height = sourceImageHeight;
      imageArray = sourceImage;
      */
      width = pluginImageWidth;
      height = pluginImageHeight;
      imageArray = pluginImage;
    } else if ((storedRmap instanceof Server) || (storedRmap instanceof Shortcut)) {
      // JPW 01/22/2002: Add support for Shortcut objects
      width = serverImageWidth;
      height = serverImageHeight;
      imageArray = serverImage;
      // JPW 02/14/2002: If this is the server the user is connected
      //                 to, make the node label stand out.
      try {
        if (storedRmap.getFullName().equals(admin.getRBNBDataManager().getServerName())) {
          defaultComp.setFont(new Font("Dialog", Font.BOLD, 12));
          defaultComp.setForeground(Color.red);
        }
      } catch (Exception exception) {
        System.err.println("ERROR obtaining full name from the Server's Rmap.");
      }
    } else if (storedRmap instanceof Sink) {
      // Test to see if this is a Mirror
      Client client = (Client) storedRmap;
      if (client.getType() == Client.MIRROR) {
        width = sinkSideMirrorImageWidth;
        height = sinkSideMirrorImageHeight;
        imageArray = sinkSideMirrorImage;
      } else {
        width = sinkImageWidth;
        height = sinkImageHeight;
        imageArray = sinkImage;
      }
    } else if (storedRmap instanceof Source) {
      // Test to see if this is a Mirror
      Client client = (Client) storedRmap;
      if (client.getType() == Client.MIRROR) {
        width = sourceSideMirrorImageWidth;
        height = sourceSideMirrorImageHeight;
        imageArray = sourceSideMirrorImage;

      } else {
        width = sourceImageWidth;
        height = sourceImageHeight;
        imageArray = sourceImage;
      }
    }

    if ((width != -1) && (height != -1) && (imageArray != null)) {
      MemoryImageSource mis = new MemoryImageSource(width, height, imageArray, 0, width);
      Image image = createImage(mis);
      icon = new ImageIcon(image);
      setIcon(icon);
    } else {
      setIcon(getDefaultLeafIcon());
    }

    return this;
  }