protected void applyDefaults() {

    expandedIcon =
        new ArrowIcon(ArrowIcon.SOUTH, UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY));
    collapsedIcon =
        new ArrowIcon(ArrowIcon.EAST, UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY));

    setBorder(
        new MatteBorder(0, 0, 0, 1, UIManager.getColor(CourierSystem.CONTROL_MID_SHADOW_KEY)));

    if (titlePanel != null) {
      titlePanel.setGradientColor1(UIManager.getColor(CourierSystem.TITLE_GRADIENT_COLOR1_KEY));
      titlePanel.setGradientColor2(UIManager.getColor(CourierSystem.TITLE_GRADIENT_COLOR2_KEY));
    }

    if (demoListLabel != null) {
      demoListLabel.setForeground(UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY));
      demoListLabel.setFont(UIManager.getFont(CourierSystem.TITLE_FONT_KEY));
    }
    if (viewPanel != null) {
      viewPanel.setBackground(UIManager.getColor(CourierSystem.SUB_PANEL_BACKGROUND_KEY));
    }
    if (collapsePanels != null) {
      for (CollapsiblePanel collapsePanel : collapsePanels) {
        collapsePanel.setFont(UIManager.getFont("CheckBox.font").deriveFont(Font.BOLD));
        collapsePanel.setForeground(UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY));
        collapsePanel.setExpandedIcon(expandedIcon);
        collapsePanel.setCollapsedIcon(collapsedIcon);
      }
    }
    revalidate();
  }
  protected void installDefaults(JXHeader h) {
    gradientLightColor = UIManager.getColor("JXHeader.startBackground");
    if (gradientLightColor == null) {
      // fallback to white
      gradientLightColor = Color.WHITE;
    }
    gradientDarkColor = UIManager.getColor("JXHeader.background");
    // for backwards compatibility (mostly for substance and synthetica,
    // I suspect) I'll fall back on the "control" color if JXHeader.background
    // isn't specified.
    if (gradientDarkColor == null) {
      gradientDarkColor = UIManager.getColor("control");
    }

    Painter p = h.getBackgroundPainter();
    if (p == null || p instanceof PainterUIResource) {
      h.setBackgroundPainter(createBackgroundPainter());
    }

    // title properties
    Font titleFont = h.getTitleFont();
    if (titleFont == null || titleFont instanceof FontUIResource) {
      titleFont = UIManager.getFont("JXHeader.titleFont");
      // fallback to label font
      titleLabel.setFont(titleFont != null ? titleFont : UIManager.getFont("Label.font"));
    }

    Color titleForeground = h.getTitleForeground();
    if (titleForeground == null || titleForeground instanceof ColorUIResource) {
      titleForeground = UIManager.getColor("JXHeader.titleForeground");
      // fallback to label foreground
      titleLabel.setForeground(
          titleForeground != null ? titleForeground : UIManager.getColor("Label.foreground"));
    }

    titleLabel.setText(h.getTitle());

    // description properties
    Font descFont = h.getDescriptionFont();
    if (descFont == null || descFont instanceof FontUIResource) {
      descFont = UIManager.getFont("JXHeader.descriptionFont");
      // fallback to label font
      descriptionPane.setFont(descFont != null ? descFont : UIManager.getFont("Label.font"));
    }

    Color descForeground = h.getDescriptionForeground();
    if (descForeground == null || descForeground instanceof ColorUIResource) {
      descForeground = UIManager.getColor("JXHeader.descriptionForeground");
      // fallback to label foreground
      descriptionPane.setForeground(
          descForeground != null ? descForeground : UIManager.getColor("Label.foreground"));
    }

    descriptionPane.setText(h.getDescription());
  }
Exemple #3
0
  /** Creates a new view. */
  public NetView() {
    initComponents();

    scrollPane.setLayout(new PlacardScrollPaneLayout());
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));

    setEditor(new DefaultDrawingEditor());
    undo = new UndoRedoManager();
    view.setDrawing(createDrawing());
    view.getDrawing().addUndoableEditListener(undo);
    initActions();
    undo.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            setHasUnsavedChanges(undo.hasSignificantEdits());
          }
        });

    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");

    JPanel placardPanel = new JPanel(new BorderLayout());
    javax.swing.AbstractButton pButton;
    pButton = ButtonFactory.createZoomButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    placardPanel.add(pButton, BorderLayout.WEST);
    toggleGridButton = pButton = ButtonFactory.createToggleGridButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    labels.configureToolBarButton(pButton, "view.toggleGrid.placard");
    placardPanel.add(pButton, BorderLayout.EAST);
    scrollPane.add(placardPanel, JScrollPane.LOWER_LEFT_CORNER);

    toggleGridButton.setSelected(preferences.getBoolean("view.gridVisible", false));
    view.setScaleFactor(preferences.getDouble("view.scaleFactor", 1d));

    view.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if ("scaleFactor".equals(name)) {
              preferences.putDouble("view.scaleFactor", (Double) evt.getNewValue());
              firePropertyChange("scaleFactor", evt.getOldValue(), evt.getNewValue());
            }
          }
        });
  }
 public SelectableText() {
   this.setEditable(false);
   this.setBackground(null); // Inherit from parent
   this.setBorder(null);
   this.setForeground(UIManager.getColor("Label.foreground"));
   this.setFont(UIManager.getFont("Label.font"));
 }
 private boolean setColumnPreferredSize() {
   boolean sizeCalculated = false;
   Font tableFont = UIManager.getFont("Table.font");
   for (int i = 0; i < getColumnCount(); i++) {
     TableColumn column = getColumnModel().getColumn(i);
     if (i == GraphTableModel.ROOT_COLUMN) { // thin stripe, or root name, or nothing
       setRootColumnSize(column);
     } else if (i
         == GraphTableModel.COMMIT_COLUMN) { // let commit message occupy as much as possible
       column.setPreferredWidth(Short.MAX_VALUE);
     } else if (i == GraphTableModel.AUTHOR_COLUMN) { // detect author with the longest name
       // to avoid querying the last row (it would lead to full graph loading)
       int maxRowsToCheck =
           Math.min(MAX_ROWS_TO_CALC_WIDTH, getRowCount() - MAX_ROWS_TO_CALC_OFFSET);
       if (maxRowsToCheck < 0) { // but if the log is small, check all of them
         maxRowsToCheck = getRowCount();
       }
       int maxWidth = 0;
       for (int row = 0; row < maxRowsToCheck; row++) {
         String value = getModel().getValueAt(row, i).toString();
         maxWidth = Math.max(getFontMetrics(tableFont).stringWidth(value), maxWidth);
         if (!value.isEmpty()) sizeCalculated = true;
       }
       column.setMinWidth(
           Math.min(maxWidth + UIUtil.DEFAULT_HGAP, MAX_DEFAULT_AUTHOR_COLUMN_WIDTH));
       column.setWidth(column.getMinWidth());
     } else if (i == GraphTableModel.DATE_COLUMN) { // all dates have nearly equal sizes
       column.setMinWidth(
           getFontMetrics(tableFont)
               .stringWidth("mm" + DateFormatUtil.formatDateTime(new Date())));
       column.setWidth(column.getMinWidth());
     }
   }
   return sizeCalculated;
 }
  @Override
  public int getRowHeight() {
    if (myRowHeightIsComputing) {
      return super.getRowHeight();
    }

    if (myRowHeight < 0) {
      try {
        myRowHeightIsComputing = true;
        for (int row = 0; row < getRowCount(); row++) {
          for (int column = 0; column < getColumnCount(); column++) {
            final TableCellRenderer renderer = getCellRenderer(row, column);
            if (renderer != null) {
              final Object value = getValueAt(row, column);
              final Component component =
                  renderer.getTableCellRendererComponent(this, value, true, true, row, column);
              if (component != null) {
                final Dimension size = component.getPreferredSize();
                myRowHeight = Math.max(size.height, myRowHeight);
              }
            }
          }
        }
      } finally {
        myRowHeightIsComputing = false;
      }
    }

    if (myMinRowHeight == null) {
      myMinRowHeight = getFontMetrics(UIManager.getFont("Label.font")).getHeight();
    }

    return Math.max(myRowHeight, myMinRowHeight);
  }
 public MyRenderComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
   super();
   this.table = table;
   this.col = col;
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   setOpaque(false);
   setFont(UIManager.getFont("TableHeader.font"));
   setForeground(UIManager.getColor("TableHeader.foreground"));
   setHorizontalAlignment(JLabel.CENTER);
   setHorizontalTextPosition(SwingConstants.LEADING);
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   if ((JTattooUtilities.getJavaVersion() >= 1.6)
       && (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel)) {
     RowSorter rowSorter = table == null ? null : table.getRowSorter();
     List keyList = rowSorter == null ? null : rowSorter.getSortKeys();
     if ((keyList != null) && (keyList.size() > 0)) {
       RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0);
       if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) {
         AbstractIconFactory iconFactory =
             ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory();
         if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) {
           setIcon(iconFactory.getUpArrowIcon());
         } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) {
           setIcon(iconFactory.getDownArrowIcon());
         }
       }
     }
   }
   gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor());
 }
Exemple #8
0
 private void setColumnPreferredSize() {
   for (int i = 0; i < getColumnCount(); i++) {
     TableColumn column = getColumnModel().getColumn(i);
     if (i == AbstractVcsLogTableModel.ROOT_COLUMN) { // thin stripe or nothing
       int rootWidth = myUI.getColorManager().isMultipleRoots() ? ROOT_INDICATOR_WIDTH : 0;
       // NB: all further instructions and their order are important, otherwise the minimum size
       // which is less than 15 won't be applied
       column.setMinWidth(rootWidth);
       column.setMaxWidth(rootWidth);
       column.setPreferredWidth(rootWidth);
     } else if (i
         == AbstractVcsLogTableModel
             .COMMIT_COLUMN) { // let commit message occupy as much as possible
       column.setPreferredWidth(Short.MAX_VALUE);
     } else if (i
         == AbstractVcsLogTableModel.AUTHOR_COLUMN) { // detect author with the longest name
       // to avoid querying the last row (it would lead to full graph loading)
       int maxRowsToCheck =
           Math.min(MAX_ROWS_TO_CALC_WIDTH, getRowCount() - MAX_ROWS_TO_CALC_OFFSET);
       if (maxRowsToCheck < 0) { // but if the log is small, check all of them
         maxRowsToCheck = getRowCount();
       }
       int contentWidth = calcMaxContentColumnWidth(i, maxRowsToCheck);
       column.setMinWidth(Math.min(contentWidth, MAX_DEFAULT_AUTHOR_COLUMN_WIDTH));
       column.setWidth(column.getMinWidth());
     } else if (i == AbstractVcsLogTableModel.DATE_COLUMN) { // all dates have nearly equal sizes
       Font tableFont = UIManager.getFont("Table.font");
       column.setMinWidth(
           getFontMetrics(tableFont)
               .stringWidth("mm" + DateFormatUtil.formatDateTime(new Date())));
       column.setWidth(column.getMinWidth());
     }
   }
 }
Exemple #9
0
 public MacRenderer() {
   renderer = new JLabel();
   renderer.setOpaque(Preferences.getBoolean("jeti", "bmw", true));
   renderer.setBackground(UIManager.getColor("Tree.selectionBackground"));
   renderer.setForeground(UIManager.getColor("Tree.textForeground"));
   renderer.setFont(UIManager.getFont("Tree.font"));
 }
  /** installs the tabbed pane related properties */
  public void installTabbedContainerSettings() {
    final String prefix = "/com/vlsolutions/swing/docking/";
    UIManager.put("TabbedDockableContainer.tabPlacement", new Integer(SwingConstants.TOP));

    UIManager.put(
        "DockTabbedPane.closeButtonText",
        UIManager.getString("InternalFrameTitlePane.closeButtonText"));
    UIManager.put(
        "DockTabbedPane.minimizeButtonText",
        UIManager.getString("InternalFrameTitlePane.minimizeButtonText"));
    UIManager.put(
        "DockTabbedPane.restoreButtonText",
        UIManager.getString("InternalFrameTitlePane.restoreButtonText"));
    UIManager.put(
        "DockTabbedPane.maximizeButtonText",
        UIManager.getString("InternalFrameTitlePane.maximizeButtonText"));
    UIManager.put("DockTabbedPane.floatButtonText", "Detach");
    UIManager.put("DockTabbedPane.attachButtonText", "Attach"); // 2005/10/07

    UIManager.put("JTabbedPaneSmartIcon.font", UIManager.getFont("TabbedPane.font")); // 2006/01/23

    // set to true to set focus directly into a tabbed component when it becomes
    // selected
    UIManager.put("TabbedContainer.requestFocusOnTabSelection", Boolean.FALSE);
  }
Exemple #11
0
 @Override
 public String convertValueToText(
     Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
   String s = super.convertValueToText(value, selected, expanded, leaf, row, hasFocus);
   String newProp = jEdit.getProperty(HIGHLIGHT_PROP);
   if (newProp == null || newProp.isEmpty()) return s;
   DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
   while (node != null && !(node.getUserObject() instanceof HyperSearchOperationNode)) {
     node = (DefaultMutableTreeNode) node.getParent();
   }
   if (node == null) return s;
   if (!newProp.equals(prop)) {
     prop = newProp;
     Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
     styleTag = HtmlUtilities.style2html(prop, f);
   }
   SearchMatcher matcher = ((HyperSearchOperationNode) node.getUserObject()).getSearchMatcher();
   int i = s.indexOf(": ");
   if (i > 0) i += 2;
   else i = 0;
   Match m;
   List<Integer> matches = new ArrayList<Integer>();
   while ((m = matcher.nextMatch(s.substring(i), true, true, true, false)) != null) {
     matches.add(i + m.start);
     matches.add(i + m.end);
     i += m.end;
   }
   return HtmlUtilities.highlightString(s, styleTag, matches);
 }
Exemple #12
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      Object source = evt.getSource();
      if (source == highlight) {
        String prop = jEdit.getProperty(HIGHLIGHT_PROP);
        Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
        SyntaxStyle style =
            new StyleEditor(
                    jEdit.getActiveView(),
                    HtmlUtilities.parseHighlightStyle(prop, f),
                    "hypersearch")
                .getStyle();
        if (style != null) jEdit.setProperty(HIGHLIGHT_PROP, GUIUtilities.getStyleString(style));
        updateHighlightStatus();
      } else if (source == clear) {
        removeAllNodes();
      } else if (source == multi) {
        multiStatus = !multiStatus;
        updateMultiStatus();

        if (!multiStatus) {
          for (int i = resultTreeRoot.getChildCount() - 2; i >= 0; i--) {
            resultTreeModel.removeNodeFromParent((MutableTreeNode) resultTreeRoot.getChildAt(i));
          }
        }
      } else if (source == stop) {
        jEdit.setTemporaryProperty("hyperSearch-stopButton", "true");
      }
    }
    protected void drawHistogram(Graphics g, MBinSummary binCnt) {
      //    ********************************
      // * Draw the histogram
      // ********************************
      MClusterSummary[] bins;
      int value;
      int height;
      int y;

      Color color;
      Font f = g.getFont();
      Font newFont = new Font(UIManager.getFont("Label.font").getName(), Font.PLAIN, 14);
      g.setFont(newFont);

      bins = binCnt.GetBins();
      // _maxBinsIndex

      // ***********************
      // draw the outliner even it is zero
      // ***********************
      value = bins[0].getCount();

      height = (int) ((double) value * _pixel_per_unit);

      y = _abs_line_height - height;

      g.setColor(MColorMgr.GetInstance().GetColor(0, MGlobal.FADE_IDX_MAX));
      g.fillRect(_bin_cur_x, y, (int) _bin_width, height);
      g.setColor(Color.BLACK);
      g.drawString(value + "", (int) _bin_cur_x, y - LABEL_HEIGHT);
      g.drawString("0", (int) _bin_cur_x, _abs_axis_height);

      _bin_cur_x += (int) _bin_width_two;

      // ***********************
      // * draw the rest
      // ***********************

      for (int idx = 1; idx <= binCnt.GetMaxBinIndex(); idx++) {

        value = bins[idx].getCount();

        if (value > 0) {

          height = (int) ((double) value * _pixel_per_unit);

          y = _abs_line_height - height;

          g.setColor(MColorMgr.GetInstance().GetColor(idx, MGlobal.FADE_IDX_MAX));
          g.fillRect(_bin_cur_x, y, (int) _bin_width, height);
          g.setColor(Color.BLACK);
          g.drawString(value + "", (int) _bin_cur_x, y - LABEL_HEIGHT);
          g.drawString(idx + "", (int) _bin_cur_x, _abs_axis_height);

          _bin_cur_x += (int) _bin_width_two;
        }
      }
      g.setFont(f);
      bins = null;
    }
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    jTextArea1 =
        new javax.swing.JTextArea() {
          public boolean isFocusTraversable() {
            return false;
          }
        };

    setLayout(new java.awt.GridBagLayout());

    jTextArea1.setColumns(40);
    jTextArea1.setEditable(false);
    jTextArea1.setFont(javax.swing.UIManager.getFont("Label.font"));
    jTextArea1.setForeground(new java.awt.Color(102, 102, 153));
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(4);
    jTextArea1.setText(
        NbBundle.getMessage(
            SystemCatalogCustomizer.class, "SystemCatalogCustomizer.readOnly.text")); // NOI18N
    jTextArea1.setWrapStyleWord(true);
    jTextArea1.setBorder(null);
    jTextArea1.setDisabledTextColor(javax.swing.UIManager.getColor("Label.foreground"));
    jTextArea1.setEnabled(false);
    jTextArea1.setOpaque(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(jTextArea1, gridBagConstraints);
  } // </editor-fold>//GEN-END:initComponents
  private JPanel createHeaderPanel() {
    final String empty = " ";

    final String title = getApplication().getMessage(getId());
    final JLabel titleLabel = new JLabel((title == null) ? empty : title);
    titleLabel.setHorizontalAlignment(SwingConstants.LEFT);
    titleLabel.setFont(UIManager.getFont("TitledBorder.font"));

    final String desc = getMessage("desc");
    final JLabel descLabel = new JLabel((desc == null) ? empty : desc);
    descLabel.setHorizontalAlignment(SwingConstants.LEFT);

    final String imagePath = getMessage("icon");
    Image image = null;
    if (imagePath != null) {
      image = getServices().getImageCache().getImage(imagePath);
    }

    final JPanel panel = new JPanel(new GridBagLayout());

    GridBagConstraints gc = new GridBagConstraints();
    gc.gridx = 0;
    gc.gridy = 0;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.insets = new Insets(5, 10, 0, 5);
    panel.add(titleLabel, gc);

    gc = new GridBagConstraints();
    gc.gridx = 0;
    gc.gridy = 1;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.insets = new Insets(5, 15, 10, 5);
    panel.add(descLabel, gc);

    if (image != null) {
      gc = new GridBagConstraints();
      gc.gridx = 1;
      gc.gridy = 0;
      gc.gridheight = 3;
      gc.anchor = GridBagConstraints.EAST;
      gc.insets = new Insets(0, 5, 0, 5);
      panel.add(new JLabel(new ImageIcon(image)), gc);
    }

    gc = new GridBagConstraints();
    gc.gridx = 0;
    gc.gridy = 2;
    gc.gridwidth = 2;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    panel.add(new JSeparator(), gc);

    panel.setBackground(UIManager.getColor("TextField.background"));
    panel.setOpaque(true);

    return panel;
  }
 private int calculateMaxRootWidth() {
   int width = 0;
   for (VirtualFile file : myLogDataHolder.getRoots()) {
     Font tableFont = UIManager.getFont("Table.font");
     width = Math.max(getFontMetrics(tableFont).stringWidth(file.getName() + "  "), width);
   }
   return width;
 }
Exemple #17
0
 HighlightingTree(DefaultTreeModel model) {
   super(model);
   prop = jEdit.getProperty(HIGHLIGHT_PROP);
   if (prop != null && !prop.isEmpty()) {
     Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
     styleTag = HtmlUtilities.style2html(prop, f);
   }
 }
 /** Configures a checkbox with the properties of tree cell renderes. */
 private static JCheckBox configureCheckBox(JCheckBox checkBox) {
   checkBox.setHorizontalAlignment(JCheckBox.LEFT);
   checkBox.setFont(UIManager.getFont("Tree.font"));
   checkBox.setBorderPainted(false);
   checkBox.setFocusPainted(false);
   checkBox.setFocusable(false);
   checkBox.setOpaque(false);
   return checkBox;
 }
Exemple #19
0
 static int getDefaultFontSize() {
   Integer customFontSize = (Integer) UIManager.get("customFontSize"); // NOI18N
   if (customFontSize != null) {
     return customFontSize.intValue();
   } else {
     Font systemDefaultFont = UIManager.getFont("TextField.font"); // NOI18N
     return (systemDefaultFont != null) ? systemDefaultFont.getSize() : 11;
   }
 }
  public static void setFontSizeDelta(float delta) {
    if (delta == 0f) {
      return;
    }

    Map<Font, Font> newFontByOldFont = new HashMap<Font, Font>();
    String[] fontKeys =
        new String[] {
          "Button.font",
          "CheckBox.font",
          "ComboBox.font",
          "DesktopIcon.font",
          "Label.font",
          "List.font",
          "ProgressBar.font",
          "RadioButton.font",
          "Slider.font",
          "Spinner.font",
          "TabbedPane.font",
          "TitledBorder.font",
          "ToggleButton.font",
          "CheckBoxMenuItem.font",
          "Menu.font",
          "MenuBar.font",
          "MenuItem.font",
          "PopupMenu.font",
          "RadioButtonMenuItem.font",
          "ToolBar.font",
          "ToolTip.font",
          "EditorPane.font",
          "FormattedTextField.font",
          "PasswordField.font",
          "Table.font",
          "TableHeader.font",
          "TextArea.font",
          "TextField.font",
          "TextPane.font",
          "Tree.font",
          "InternalFrame.titleFont",
        };
    List<Object> props = new ArrayList<Object>(fontKeys.length * 2);
    for (String fontKey : fontKeys) {
      Font font = UIManager.getFont(fontKey);
      Font newFont = newFontByOldFont.get(font);
      if (newFont == null) {
        if (font == null) {
          continue;
        }
        newFont = new FontUIResource(font.deriveFont(font.getSize() + delta));
        newFontByOldFont.put(font, newFont);
      }
      props.add(fontKey);
      props.add(newFont);
    }
    UIManager.getDefaults().putDefaults(props.toArray());
  }
Exemple #21
0
  /**
   * Creates component.
   *
   * @param collection collection to show.
   * @param treeMode <code>TRUE</code> to set tree mode by default.
   * @param readingLists <code>TRUE</code> if showing reading lists.
   */
  public CListTree(Collection collection, boolean treeMode, boolean readingLists) {
    this.collection = collection;
    this.readingLists = readingLists;

    itemListener = new CItemListener();

    setLayout(new BorderLayout());
    setTreeMode(treeMode);

    BBFormBuilder builder = new BBFormBuilder("p, 2dlu, p, 0:grow");

    JComboBox cbViewMode =
        new JComboBox(
            new Object[] {
              Strings.message("collections.viewmode.tree"),
              Strings.message("collections.viewmode.list")
            });
    cbViewMode.setSelectedIndex(treeMode ? 0 : 1);
    cbViewMode.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            JComboBox box = (JComboBox) e.getSource();
            boolean isTree = box.getSelectedIndex() == 0;
            setTreeMode(isTree);
          }
        });

    builder.append(Strings.message("collections.viewmode"), cbViewMode);
    builder.appendRelatedComponentsGapRow(2);

    add(builder.getPanel(), BorderLayout.NORTH);

    // Description area
    taDescription = new JEditorPane();
    Color back = taDescription.getBackground();
    taDescription.setEditable(false);
    taDescription.setBackground(back);
    taDescription.setEditorKit(new CustomHTMLEditorKit());

    HTMLDocument doc = (HTMLDocument) taDescription.getDocument();
    Style def = doc.getStyle("default");
    Font font = UIManager.getFont("TextArea.font");
    if (SystemUtils.IS_OS_MAC) font = UifUtilities.applyFontBias(font, -2);
    UifUtilities.setFontAttributes(doc.addStyle(TEXT_STYLE, def), font);

    builder = new BBFormBuilder("0:grow");
    builder.appendUnrelatedComponentsGapRow(2);
    builder.appendRow("p");

    builder.append(Strings.message("collections.description"), 1);
    builder.appendRelatedComponentsGapRow(2);
    builder.appendRow("50px");
    builder.append(taDescription, 1, CellConstraints.FILL, CellConstraints.FILL);

    add(builder.getPanel(), BorderLayout.SOUTH);
  }
 private void calculateBaseUnits() {
   // This calculation comes from:
   // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
   FontMetrics metrics =
       Toolkit.getDefaultToolkit().getFontMetrics(UIManager.getFont("Button.font"));
   baseUnitX = metrics.stringWidth("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
   baseUnitX = (baseUnitX / 26 + 1) / 2;
   // The -1 comes from experimentation.
   baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
 }
Exemple #23
0
public class POSTitleLabel extends JLabel {
  private static Font font =
      UIManager.getFont("Label.font").deriveFont(Font.BOLD, 12); // $NON-NLS-1$
  private static Color forground = Color.black;

  public POSTitleLabel() {
    setFont(font);
    setForeground(forground);
  }
}
 public SortedTableHeaderRenderer(TableSorter sorter) {
   this.m_sorter = sorter;
   setOpaque(true);
   setForeground(UIManager.getColor("TableHeader.foreground"));
   setBackground(UIManager.getColor("TableHeader.background"));
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   setFont(UIManager.getFont("TableHeader.font"));
   setHorizontalTextPosition(SwingConstants.LEFT);
   this.setIconTextGap(2);
 }
 public WrappableJLabel(double width) {
   setWrapStyleWord(true);
   setLineWrap(true);
   setOpaque(false);
   setEditable(false);
   setFocusable(false);
   setBackground(UIManager.getColor("Label.background"));
   setFont(UIManager.getFont("Label.font"));
   setBorder(UIManager.getBorder("Label.border"));
 }
Exemple #26
0
  public MultiLabel(String str, int horizontalAlignment, int textAlignment, int verticalAlignment) {
    this.setForeground(UIManager.getColor("Label.foreground"));
    this.setBackground(UIManager.getColor("Label.background"));
    this.setFont(UIManager.getFont("Label.font"));

    setText(str);
    this.horizontalAlignment = horizontalAlignment;
    this.textAlignment = textAlignment;
    this.verticalAlignment = verticalAlignment;
  }
Exemple #27
0
/**
 * An extension of the UIManager class that contains Fields which define the look and feel of the
 * ARO Data Analyzer application.
 */
public class AROUIManager extends UIManager {

  private static final long serialVersionUID = 1L;

  /** The Key that is used to map the title font style in the underlying UIManager class. */
  public static final String TITLE_FONT_KEY = "TITLEFont";

  /** The Key that is used to map the label font style in the underlying UIManager class. */
  public static final String LABEL_FONT_KEY = "Label.font";

  /** The Key that is used to map the background Color in the underlying UIManager class. */
  public static final String PAGE_BACKGROUND_KEY = "page.background";

  /** The Font style used for headers. */
  public static final Font HEADER_FONT = new Font("Arial Narrow", Font.BOLD, 20);

  /** The Font style used for ARO Data Analyzer labels. */
  public static Font LABEL_FONT = UIManager.getFont("Label.font").deriveFont(Font.BOLD);

  /** The color used in the ARO Data Analyzer chart fields. */
  public static final Color CHART_BAR_COLOR = new Color(64, 164, 223);

  static {
    String os = System.getProperty("os.name").toLowerCase();
    if (os.indexOf("mac") >= 0) {
      LABEL_FONT = new Font("Arial Narrow", Font.BOLD, 12);
    }
    try {
      // sets the look and feel of the ARO executing environment
      setLookAndFeel(getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
      e.printStackTrace();
    }
  }

  /**
   * Initializes the AROUIManager with the styles that form the default the look and feel of the ARO
   * Data Analyzer.
   */
  public static void init() {
    put(TITLE_FONT_KEY, new Font(TITLE_FONT_KEY, Font.BOLD, 18));
    put(PAGE_BACKGROUND_KEY, Color.WHITE);
    put(LABEL_FONT_KEY, LABEL_FONT);

    /* Tool tip visibility delay configured. */
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setDismissDelay(8000);
  }
}
Exemple #28
0
 // {{{ parseHighlightStyle()
 SyntaxStyle parseHighlightStyle(String style) {
   Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
   SyntaxStyle s;
   try {
     s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true, null);
   } catch (Exception e) {
     style = "color:#000000";
     s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true);
   }
   return s;
 } // }}}
 protected void installDefaults() {
   super.installDefaults();
   setFont(UIManager.getFont("InternalFrame.titleFont"));
   paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight");
   paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
   wasClosable = frame.isClosable();
   selectedForegroundKey = selectedBackgroundKey = null;
   if (MetalLookAndFeel.usingOcean()) {
     setOpaque(true);
   }
 }
 public static void installColorsAndFont(
     final JComponent comp,
     final String background,
     final String foreground,
     final String fontName) {
   installColors(comp, background, foreground);
   Font font = comp.getFont();
   if (Utilities.isUIResource(font)) {
     comp.setFont(UIManager.getFont(fontName));
   }
 }