Esempio n. 1
0
  private void drawWinBorder(Component c, Graphics g, int x, int y, int w, int h) {
    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderColor[Theme.style].getColor());
    }
    g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
    g.drawLine(x + 1, y + 2, x + 1, y + h - 3);

    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderDarkDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderDarkColor[Theme.style].getColor());
    }
    g.drawLine(x, y, x + w - 2, y);
    g.drawLine(x, y + 1, x, y + h - 2);

    g.setColor(Theme.backColor[Theme.style].getColor());
    g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
    g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);

    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderLightDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderLightColor[Theme.style].getColor());
    }
    g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
    g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
  }
Esempio n. 2
0
 protected java.awt.Color getTextColor(java.awt.Component c) {
   if (c.isEnabled()) {
     return java.awt.Color.BLACK;
   } else {
     return java.awt.Color.GRAY;
   }
 }
 private Component cycle(Component currentComponent, int delta) {
   int index = -1;
   loop:
   for (int i = 0; i < m_Components.length; i++) {
     Component component = m_Components[i];
     for (Component c = currentComponent; c != null; c = c.getParent()) {
       if (component == c) {
         index = i;
         break loop;
       }
     }
   }
   // try to find enabled component in "delta" direction
   int initialIndex = index;
   while (true) {
     int newIndex = indexCycle(index, delta);
     if (newIndex == initialIndex) {
       break;
     }
     index = newIndex;
     //
     Component component = m_Components[newIndex];
     if (component.isEnabled() && component.isVisible() && component.isFocusable()) {
       return component;
     }
   }
   // not found
   return currentComponent;
 }
Esempio n. 4
0
 private void drawXpBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (!c.isEnabled()) {
     DrawRoutines.drawBorder(g, Theme.textBorderDisabledColor[Theme.style].getColor(), x, y, w, h);
   } else {
     DrawRoutines.drawBorder(g, Theme.textBorderColor[Theme.style].getColor(), x, y, w, h);
   }
 }
Esempio n. 5
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (c.isEnabled()) {
     MetalUtils.drawFlush3DBorder(g, x, y, w, h);
   } else {
     MetalUtils.drawDisabledBorder(g, x, y, w, h);
   }
 }
Esempio n. 6
0
  public void enableControlPanel() {
    boolean bVisible = false;

    int nmembers = buttonPane.getComponentCount();
    for (int k = 0; k < nmembers; k++) {
      Component comp = buttonPane.getComponent(k);
      if (comp != null) {
        if (comp.isVisible() || comp.isEnabled()) {
          bVisible = true;
          break;
        }
      }
    }

    if (bVisible && !buttonPane.isVisible()) {
      Dimension dim = getSize();
      Dimension dim1 = buttonPane.getPreferredSize();
      int w = dim.width;
      int h = dim.height + dim1.height;
      if (dim1.width > w) w = dim1.width;
      if (w < 300) w = 300;
      if (h < 200) h = 200;
      setSize(w, h);
    }
    buttonPane.setVisible(bVisible);
  }
    public void paintIcon(Component c, Graphics g, int x, int y) {
      boolean enabled = c.isEnabled();

      // paint the icon
      Icon paintedIcon = enabled ? icon : disabledIcon;
      if (paintedIcon != null) paintedIcon.paintIcon(c, g, x, y);

      // backup current color
      Color oldColor = g.getColor();
      int insetx = 4;
      if (c instanceof JComponent) {
        Insets borderinset = ((JComponent) c).getBorder().getBorderInsets(c);
        insetx = borderinset.left;
      }
      if (paintedIcon != null) {
        g.translate(paintedIcon.getIconWidth() + X_GAP + insetx, 0);
      }

      arrow.paintIcon(c, g, x, y);
      if (paintedIcon != null) {
        g.translate(-paintedIcon.getIconWidth() - X_GAP - insetx, 0);
      }

      // restore previous color
      g.setColor(oldColor);
    }
  private boolean accept(Component aComponent) {
    if (!(aComponent.isVisible()
        && aComponent.isDisplayable()
        && aComponent.isFocusable()
        && aComponent.isEnabled())) {
      return false;
    }

    // Verify that the Component is recursively enabled. Disabling a
    // heavyweight Container disables its children, whereas disabling
    // a lightweight Container does not.
    if (!(aComponent instanceof Window)) {
      for (Container enableTest = aComponent.getParent();
          enableTest != null;
          enableTest = enableTest.getParent()) {
        if (!(enableTest.isEnabled() || enableTest.isLightweight())) {
          return false;
        }
        if (enableTest instanceof Window) {
          break;
        }
      }
    }

    return true;
  }
Esempio n. 9
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {

      if (!(c instanceof JTextComponent)) {
        // special case for non-text components (bug ID 4144840)
        if (c.isEnabled()) {
          MetalUtils.drawFlush3DBorder(g, x, y, w, h);
        } else {
          MetalUtils.drawDisabledBorder(g, x, y, w, h);
        }
        return;
      }

      if (c.isEnabled() && ((JTextComponent) c).isEditable()) {
        MetalUtils.drawFlush3DBorder(g, x, y, w, h);
      } else {
        MetalUtils.drawDisabledBorder(g, x, y, w, h);
      }
    }
    public void paintIcon(Component c, Graphics g, int x, int y) {
      Color oldColor = g.getColor();
      boolean enabled = c.isEnabled();
      boolean pressed = false;
      if (c instanceof JButton) {
        pressed = ((JButton) c).getModel().isPressed();
      }

      int i = 0;
      int j = 0;
      int w = Math.min(width, c.getWidth());
      int h = c.getHeight();
      if (h < 5 || w < 5) { // not enough space for the arrow
        g.setColor(oldColor);
        return;
      }

      int size = Math.min(h / 2, w / 2);
      size = Math.max(size, 2);
      int mid = size / 2;

      x = ((w - size) / 2); // center arrow
      y = (h - size) / 2; // center arrow
      if (pressed) {
        x++;
        y++;
      }
      g.translate(x, y); // move the x,y origin in the graphic

      if (enabled) g.setColor(UIManager.getColor("controlDkShadow")); // NOT
      // LOCALIZABLE
      else g.setColor(UIManager.getColor("controlShadow")); // NOT
      // LOCALIZABLE

      if (!enabled) {
        g.translate(1, 1);
        g.setColor(UIManager.getColor("controlLtHighlight")); // NOT
        // LOCALIZABLE
        for (i = size - 1; i >= 0; i--) {
          g.drawLine(mid - i, j, mid + i, j);
          j++;
        }
        g.translate(-1, -1);
        g.setColor(UIManager.getColor("controlShadow")); // NOT
        // LOCALIZABLE
      }

      j = 0;
      for (i = size - 1; i >= 0; i--) {
        g.drawLine(mid - i, j, mid + i, j);
        j++;
      }

      g.translate(-x, -y);
      g.setColor(oldColor);
    }
Esempio n. 11
0
  public void setEnabled(boolean val) {

    GuiUtils.throwIfNotOnEDT();

    for (Component comp : components) {
      if (comp != null && comp.isEnabled() != val) {
        comp.setEnabled(val);
      }
    }
  }
Esempio n. 12
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Dimension size = c.getSize();
   Graphics g2 = g.create(size.width / 2 - 5, size.height / 2 - 5, 10, 10);
   g2.setColor(Color.GRAY);
   g2.drawPolygon(xPoints, yPoints, 3);
   if (c.isEnabled()) {
     g2.setColor(Color.BLACK);
     g2.fillPolygon(xPoints, yPoints, 3);
   }
   g2.dispose();
 }
  protected Icon getIcon(Component c) {
    Icon icon;
    boolean isActive = true; // QuaquaUtilities.isOnActiveWindow(c);

    if (c instanceof JSlider) {
      JSlider slider = (JSlider) c;
      if (isActive) {
        if (c.isEnabled()) {
          if (slider.getModel().getValueIsAdjusting()) {
            icon = icons[EP];
          } else {
            icon = icons[E];
          }
        } else {
          icon = icons[D];
        }
      } else {
        if (c.isEnabled()) {
          icon = icons[I];
        } else {
          icon = icons[DI];
        }
      }
    } else {
      if (isActive) {
        if (c.isEnabled()) {
          icon = icons[E];
        } else {
          icon = icons[D];
        }
      } else {
        if (c.isEnabled()) {
          icon = icons[I];
        } else {
          icon = icons[DI];
        }
      }
    }
    return icon;
  }
Esempio n. 14
0
 /**
  * This method navigates in the given direction giving focus to the next component in the given
  * direction.
  *
  * @param direction The direction to give focus to.
  */
 protected void navigateFocusedComp(int direction) {
   int count = toolBar.getComponentCount();
   switch (direction) {
     case EAST:
     case SOUTH:
       if (focusedCompIndex >= 0 && focusedCompIndex < count) {
         int i = focusedCompIndex + 1;
         boolean focusRequested = false;
         // Find component to focus and request focus on it.
         while (i != focusedCompIndex && !focusRequested) {
           if (i >= count) i = 0;
           Component comp = toolBar.getComponentAtIndex(i++);
           if (comp != null && comp.isFocusable() && comp.isEnabled()) {
             comp.requestFocus();
             focusRequested = true;
           }
         }
       }
       break;
     case WEST:
     case NORTH:
       if (focusedCompIndex >= 0 && focusedCompIndex < count) {
         int i = focusedCompIndex - 1;
         boolean focusRequested = false;
         // Find component to focus and request focus on it.
         while (i != focusedCompIndex && !focusRequested) {
           if (i < 0) i = count - 1;
           Component comp = toolBar.getComponentAtIndex(i--);
           if (comp != null && comp.isFocusable() && comp.isEnabled()) {
             comp.requestFocus();
             focusRequested = true;
           }
         }
       }
       break;
     default:
       break;
   }
 }
  private ImageSet getImageSet(Component objectToPaint) {
    ImageSet retVal;

    if (!objectToPaint.isEnabled()) {
      retVal = fDisabledImageSet;
    } else if (WindowUtils.isParentWindowFocused(objectToPaint)) {
      retVal = fActiveImageSet;
    } else {
      retVal = fInactiveImageSet;
    }

    return retVal;
  }
Esempio n. 16
0
 @Override
 public void mouseClicked(MouseEvent e) {
   Component clicked = e.getComponent();
   if (clicked.isEnabled()) {
     if (clicked.equals(this.rec)) {
       if (loadInstrument()) {
         this.railBoard.getController().setIsLearningMode(false);
         setRunningState(true);
         createSequence();
         this.isRecording = true;
       }
     } else if (clicked.equals(this.play)) {
       if (loadInstrument()) {
         setRunningState(true);
         this.sequence.reproduce();
         this.isReproducing = true;
       }
     } else if (clicked.equals(this.stop)) {
       if (unloadInstrument()) {
         setRunningState(false);
         if (this.isRecording) {
           File saved = null;
           if (!this.sequence.getRecords().isEmpty()) {
             saved = VFileManager.instance.saveSecuence(this.sequence);
           }
           this.sequence = saved == null ? null : this.sequence;
           this.isRecording = false;
           this.player.stopRecording();
           loadSequence();
         } else if (this.isReproducing) {
           this.sequence.stop();
           this.isReproducing = false;
         }
         this.railBoard.clear();
       }
     } else if (clicked.equals(this.loadSecuenceButton)) {
       this.sequence = VFileManager.instance.readSequence();
       loadSequence();
     }
   }
 }
    protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) {
      if (!c.isEnabled()) {
        return;
      }

      Color oldColor = g.getColor();
      int h = height;
      int w = width;

      g.translate(x, y);

      g.setColor(getHighlightInnerColor(c));
      g.drawLine(0, 0, 0, h - 1);
      g.drawLine(1, 0, w - 1, 0);

      g.setColor(getShadowOuterColor(c));
      g.drawLine(0, h - 1, w - 1, h - 1);
      g.drawLine(w - 1, 0, w - 1, h - 2);

      g.translate(-x, -y);
      g.setColor(oldColor);
    }
Esempio n. 18
0
 protected void paintBackground(Graphics g, Rectangle cellRect, int col) {
   Component component = getHeaderRenderer(col);
   int x = cellRect.x;
   int y = cellRect.y;
   int w = cellRect.width;
   int h = cellRect.height;
   if (header.getBackground() instanceof ColorUIResource) {
     if ((col == rolloverCol) && (component != null) && component.isEnabled()) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getRolloverColors(), x, y, w, h);
     } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), x, y, w, h);
     } else {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), x, y, w, h);
     }
   } else {
     g.setColor(header.getBackground());
     g.fillRect(x, y, w, h);
   }
 }
Esempio n. 19
0
  public JToolBar buildToolBar(MutableGuiContext ctxt) throws MenuFactory.BuildException {
    JToolBar bar = new JToolBar();
    bar.setFloatable(getFloatable());
    bar.setBorderPainted(getBorderPainted());

    for (MenuBuilder item : getComponents()) {
      item.setForMenu(false);

      Component cmp = item.build(ctxt);

      if (cmp instanceof JMenuItem && ((JMenuItem) cmp).getIcon() != null) {

        Action currentAction = ((JMenuItem) cmp).getAction();
        if (!item.isHiddenWhenNotAllowed() || currentAction.isEnabled()) {
          bar.add(currentAction).setName(currentAction.getValue(Action.NAME).toString());
          ;
        }

      } else {
        if (cmp instanceof AbstractButton) {
          Action actionObject = ((AbstractButton) cmp).getAction();
          if (actionObject != null) {
            String actionName = (String) actionObject.getValue(Action.NAME);
            cmp.setName(actionName);
          }
        }
        if (getIconOnly() && cmp instanceof JButton && ((JButton) cmp).getIcon() != null) {
          ((JButton) cmp).setText("");
        }
        if (!item.isHiddenWhenNotAllowed() || cmp.isEnabled()) {
          bar.add(cmp);
        }
      }
    }
    rolloverEffect.doEffect(bar);
    return removeUnnecessarySeparators(bar);
  }
Esempio n. 20
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   AbstractButton button = (AbstractButton) c;
   ButtonModel model = button.getModel();
   if (MetalLookAndFeel.usingOcean()) {
     if (model.isArmed() || !button.isEnabled()) {
       super.paintBorder(c, g, x, y, w, h);
     } else {
       g.setColor(MetalLookAndFeel.getControlDarkShadow());
       g.drawRect(0, 0, w - 1, h - 1);
     }
     return;
   }
   if (!c.isEnabled()) {
     MetalUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
   } else {
     if (model.isPressed() && model.isArmed()) {
       MetalUtils.drawPressed3DBorder(g, x, y, w, h);
     } else if (model.isSelected()) {
       MetalUtils.drawDark3DBorder(g, x, y, w, h);
     } else {
       MetalUtils.drawFlush3DBorder(g, x, y, w, h);
     }
   }
 }
Esempio n. 21
0
 /**
  * Sets the help text for the specified component.
  *
  * @param cont input container
  */
 static void focus(final Component cont) {
   final GUI gui = gui(cont);
   if (gui == null) return;
   if (gui.gopts.get(GUIOptions.MOUSEFOCUS) && cont.isEnabled()) cont.requestFocusInWindow();
 }
 private Component getEnabledComponentBefore(
     final Container container, final Component component) {
   return (component.isEnabled() ? component : getComponentBefore(container, component));
 }
Esempio n. 23
0
 private TitledSeparator getTitledSeparator(Component c) {
   titledSeparator.setEnabled(c.isEnabled());
   return titledSeparator;
 }
 public static boolean isFocusable(Component component) {
   return component.isFocusable()
       && component.isDisplayable()
       && component.isVisible()
       && component.isEnabled();
 }