Esempio n. 1
0
 private static int getAquaTabbedPaneBaseline(JTabbedPane tp, int height) {
   Font font = tp.getFont();
   FontMetrics metrics = tp.getFontMetrics(font);
   int ascent = metrics.getAscent();
   int offset;
   switch (tp.getTabPlacement()) {
     case JTabbedPane.TOP:
       offset = 5;
       if (tp.getFont().getSize() > 12) {
         offset = 6;
       }
       int yOffset = 20 - metrics.getHeight();
       yOffset /= 2;
       return offset + yOffset + ascent - 1;
     case JTabbedPane.BOTTOM:
       if (tp.getFont().getSize() > 12) {
         offset = 6;
       } else {
         offset = 4;
       }
       return height - (20 - ((20 - metrics.getHeight()) / 2 + ascent)) - offset;
     case JTabbedPane.LEFT:
     case JTabbedPane.RIGHT:
       // Aqua rotates left/right text, so that there isn't a good
       // baseline.
       return -1;
   }
   return -1;
 }
Esempio n. 2
0
  public Editor(T document) {
    super(new BorderLayout());
    this.document = document;

    setBackground(Color.LIGHT_GRAY);
    inputTabs = new JTabbedPane(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT);
    inputTabs.setUI(new VerticalTabbedPaneUI());

    inputTabs.setFont(inputTabs.getFont().deriveFont(8));
    inputTabsChangeListener = new InputTabsChangeListener();
    inputTabs.addChangeListener(inputTabsChangeListener);

    inspectorPanel = JInspectorPanelFactory.build(inputTabs);
    add(inspectorPanel.getComponent(), BorderLayout.CENTER);
  }
Esempio n. 3
0
 private static int getMaxTabHeight(JTabbedPane tp) {
   int fontHeight = tp.getFontMetrics(tp.getFont()).getHeight();
   int height = fontHeight;
   boolean tallerIcons = false;
   for (int counter = tp.getTabCount() - 1; counter >= 0; counter--) {
     Icon icon = tp.getIconAt(counter);
     if (icon != null) {
       int iconHeight = icon.getIconHeight();
       height = Math.max(height, iconHeight);
       if (iconHeight > fontHeight) {
         tallerIcons = true;
       }
     }
   }
   Insets tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
   height += 2;
   if (!isMetal() || !tallerIcons) {
     height += tabInsets.top + tabInsets.bottom;
   }
   return height;
 }
Esempio n. 4
0
 private static int getTabbedPaneBaseline(JTabbedPane tp, int height) {
   if (tp.getTabCount() > 0) {
     if (isAqua()) {
       return getAquaTabbedPaneBaseline(tp, height);
     }
     Insets insets = tp.getInsets();
     Insets contentBorderInsets = UIManager.getInsets("TabbedPane.contentBorderInsets");
     Insets tabAreaInsets =
         rotateInsets(UIManager.getInsets("TabbedPane.tabAreaInsets"), tp.getTabPlacement());
     FontMetrics metrics = tp.getFontMetrics(tp.getFont());
     int maxHeight = getMaxTabHeight(tp);
     iconRect.setBounds(0, 0, 0, 0);
     textRect.setBounds(0, 0, 0, 0);
     viewRect.setBounds(0, 0, Short.MAX_VALUE, maxHeight);
     SwingUtilities.layoutCompoundLabel(
         tp,
         metrics,
         "A",
         null,
         SwingUtilities.CENTER,
         SwingUtilities.CENTER,
         SwingUtilities.CENTER,
         SwingUtilities.TRAILING,
         viewRect,
         iconRect,
         textRect,
         0);
     int baseline = textRect.y + metrics.getAscent();
     switch (tp.getTabPlacement()) {
       case JTabbedPane.TOP:
         baseline += insets.top + tabAreaInsets.top;
         if (isWindows()) {
           if (tp.getTabCount() > 1) {
             baseline += 1;
           } else {
             baseline -= 1;
           }
         }
         return baseline;
       case JTabbedPane.BOTTOM:
         baseline = tp.getHeight() - insets.bottom - tabAreaInsets.bottom - maxHeight + baseline;
         if (isWindows()) {
           if (tp.getTabCount() > 1) {
             baseline += -1;
           } else {
             baseline += 1;
           }
         }
         return baseline;
       case JTabbedPane.LEFT:
       case JTabbedPane.RIGHT:
         if (isAqua()) {
           // Aqua rotates left/right text, so that there isn't a good
           // baseline.
           return -1;
         }
         baseline += insets.top + tabAreaInsets.top;
         if (isWindows()) {
           baseline += (maxHeight % 2);
         }
         return baseline;
     }
   }
   return -1;
 }