Exemplo n.º 1
0
  /**
   * Fill Background with Color. (Ususlly called from update methods)
   *
   * @param g2D Graphics
   * @param c Component
   * @param round paint round corners
   */
  public static void fillRectange(Graphics2D g2D, JComponent c, boolean round) {
    //  Paint in AdempiereColor?
    CompiereColor cc = null;
    boolean stdCC = c.getClientProperty(CompiereLookAndFeel.BACKGROUND_FILL) != null;
    try {
      cc = (CompiereColor) c.getClientProperty(CompiereLookAndFeel.BACKGROUND);
    } catch (Exception e) {
      stdCC = true;
    }
    if (stdCC) cc = CompiereColor.getDefaultBackground();

    //  Paint AdempiereColor
    if (cc != null) {
      //  bounds is often not within Panel bouunds
      cc.paint(g2D, c);
    }
    //  Paint Flat Color
    else {
      Paint paint = c.getBackground();
      g2D.setPaint(paint);
      //
      RectangularShape rec = null;
      if (round) rec = new RoundRectangle2D.Float(0, 0, c.getWidth(), c.getHeight(), 15, 15);
      else rec = new Rectangle(0, 0, c.getWidth(), c.getHeight());
      g2D.fill(rec);
    }
  } //  fill Rectangle
  public void update(Graphics g, JComponent c) {
    if (c.isOpaque()) {
      AbstractButton b = (AbstractButton) c;
      if (isToolBarButton(b)) {
        c.setOpaque(false);
      } else if (b.isContentAreaFilled()) {
        g.setColor(c.getBackground());
        g.fillRect(0, 0, c.getWidth(), c.getHeight());

        if (is3D(b)) {
          Color color1 = c.getBackground(); // UIManager.getColor("control");
          Color color2 = color1.brighter();

          int x = 0;
          int y = 0;
          int width = c.getWidth();
          int height = c.getHeight();
          GradientPaint gp = new GradientPaint(x, y, color2, width - 2, height - 2, color1, true);
          Graphics2D g2 = (Graphics2D) g;
          g2.setPaint(gp);
          g2.fillRect(x, y, width, height);
        }
      }
    }
    c.setBorder(defaultBorder);
    paint(g, c);
  }
  @Override
  protected void paintBackground(Graphics g, JComponent component) {
    getGlassParameters();
    Graphics2D g2d = (Graphics2D) g.create();

    if (getOrientation().isHorizontal()) {
      paintBackground(
          g2d,
          0,
          0,
          component.getWidth(),
          component.getHeight(),
          getOrientation().isHorizontal(),
          component);
    } else {
      paintBackground(
          g2d,
          0,
          0,
          component.getHeight(),
          component.getWidth(),
          getOrientation().isHorizontal(),
          component);
    }

    g2d.dispose();
  }
Exemplo n.º 4
0
  /**
   * Paints the pressed ui.
   *
   * @param buttonModel the instance of IButtonModel
   * @param g the instance of Graphics
   * @param c the instance of JComponent
   */
  public void paintPressed(IButtonModel buttonModel, Graphics g, JComponent c) {
    g.setColor(darkColor);
    g.drawLine(0, 0, c.getWidth() - 1, 0); // top
    g.drawLine(0, 0, 0, c.getHeight() - 1); // left

    g.setColor(brightColor);
    g.drawLine(0, c.getHeight() - 1, c.getWidth() - 1, c.getHeight() - 1); // bottom
    g.drawLine(c.getWidth() - 1, 0, c.getWidth() - 1, c.getHeight() - 1); // right
  }
Exemplo n.º 5
0
  @Override
  public void paint(Graphics g, JComponent c) {
    JButton button = (JButton) c;
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if ((icon == null) && (text == null)) {
      return;
    }

    FontMetrics fm = g.getFontMetrics();
    paintViewInsets = c.getInsets(paintViewInsets);

    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;

    // Use inverted height & width
    paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
    paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;

    Graphics2D g2 = (Graphics2D) g;
    AffineTransform tr = g2.getTransform();

    if (angle == 90) {
      g2.rotate(Math.PI / 2);
      g2.translate(0, -c.getWidth());
      paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
      paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
    } else if (angle == 270) {
      g2.rotate(-Math.PI / 2);
      g2.translate(-c.getHeight(), 0);
      paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
      paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
    }

    if (icon != null) {
      icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
    }

    if (text != null) {
      int textX = paintTextR.x;
      int textY = paintTextR.y + fm.getAscent();

      if (button.isEnabled()) {
        paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
      } else {
        paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
      }
    }

    g2.setTransform(tr);
  }
Exemplo n.º 6
0
 public void update(Graphics g, JComponent c) {
   if (c.isOpaque()) {
     g.setColor(c.getBackground());
     g.fillRect(0, 0, c.getWidth(), c.getHeight());
     if (is3D()) {
       Rectangle bounds = new Rectangle(0, 0, c.getWidth(), c.getHeight());
       boolean isHorizontal = ((JToolBar) c).getOrientation() == SwingConstants.HORIZONTAL;
       PlasticUtils.addLight3DEffekt(g, bounds, isHorizontal);
     }
   }
   paint(g, c);
 }
Exemplo n.º 7
0
    @Override
    public void paint(Graphics g, JComponent comp) {
      Graphics2D g2 = (Graphics2D) g;
      g2.setColor(Colors.GRAY);
      g2.fillRect(0, 0, comp.getWidth(), comp.getHeight());

      ListCellRenderer renderer = ((JComboBox) comp).getRenderer();
      Component c =
          renderer.getListCellRendererComponent(
              this.listBox, ((JComboBox) comp).getSelectedItem(), -1, false, false);
      this.currentValuePane.paintComponent(
          g2, c, this.comboBox, 0, 0, comp.getWidth(), comp.getHeight());
    }
Exemplo n.º 8
0
 /**
  * DOCUMENT ME!
  *
  * @param context DOCUMENT ME!
  * @param g DOCUMENT ME!
  * @param c DOCUMENT ME!
  */
 void paintBackground(SeaGlassContext context, Graphics g, JComponent c) {
   context.getPainter().paintTextFieldBackground(context, g, 0, 0, c.getWidth(), c.getHeight());
   // If necessary, paint the placeholder text.
   if (placeholderText != null && ((JTextComponent) c).getText().length() == 0 && !c.hasFocus()) {
     paintPlaceholderText(context, g, c);
   }
 }
 private void initShape(JComponent c) {
   if (!c.getBounds().equals(base)) {
     base = c.getBounds();
     shape =
         new RoundRectangle2D.Float(
             0, 0, c.getWidth() - 1, c.getHeight() - 1, arcwidth, archeight);
     border =
         new RoundRectangle2D.Float(
             focusstroke,
             focusstroke,
             c.getWidth() - 1 - focusstroke * 2,
             c.getHeight() - 1 - focusstroke * 2,
             arcwidth,
             archeight);
   }
 }
Exemplo n.º 10
0
  public static int getRoundedInteriorCorner(JComponent c) {
    if (!(c.getBorder() instanceof PBorder) && !(c.getBorder() instanceof PRoundBorder)) {
      return 0;
    }

    int h = c.getHeight() - (getBorderSize(c) * 2);
    int roundCorner = h;

    String ctype = (String) c.getClientProperty("JComponent.type");
    if (ctype != null) {
      if (ctype.equals("roundRect")) {
        return roundCorner;
      } else if (ctype.equals("square")) {
        return 0;
      } else if (ctype.equals("normal")) {
        return DEFAULT_ROUND_CORNER;
      }
    }

    Integer maxRoundCorner = (Integer) c.getClientProperty("maxRoundCorner");
    if (maxRoundCorner != null && maxRoundCorner >= 0) {
      roundCorner = Math.min(roundCorner, maxRoundCorner);
    }
    return roundCorner;
  }
Exemplo n.º 11
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {

      JScrollPane scroll = (JScrollPane) c;
      JComponent colHeader = scroll.getColumnHeader();
      int colHeaderHeight = 0;
      if (colHeader != null) colHeaderHeight = colHeader.getHeight();

      JComponent rowHeader = scroll.getRowHeader();
      int rowHeaderWidth = 0;
      if (rowHeader != null) rowHeaderWidth = rowHeader.getWidth();

      g.translate(x, y);

      g.setColor(MetalLookAndFeel.getControlDarkShadow());
      g.drawRect(0, 0, w - 2, h - 2);
      g.setColor(MetalLookAndFeel.getControlHighlight());

      g.drawLine(w - 1, 1, w - 1, h - 1);
      g.drawLine(1, h - 1, w - 1, h - 1);

      g.setColor(MetalLookAndFeel.getControl());
      g.drawLine(w - 2, 2 + colHeaderHeight, w - 2, 2 + colHeaderHeight);
      g.drawLine(1 + rowHeaderWidth, h - 2, 1 + rowHeaderWidth, h - 2);

      g.translate(-x, -y);
    }
Exemplo n.º 12
0
  public void showDialog(JComponent dialog) {
    closeDialog();

    JRootPane rootPane = SwingUtilities.getRootPane(mainPanel);
    if (rootPane == null) {
      log.severe("could not find root pane for viewer to show dialog " + dialog);
    } else {
      JLayeredPane layeredPane = rootPane.getLayeredPane();
      Dimension d = dialog.getPreferredSize();
      if (dialogPanel == null) {
        dialogPanel = new DialogPanel(this, new BorderLayout());
      }
      Insets insets = dialogPanel.getInsets();
      int width = viewerPanel.getWidth() - insets.left - insets.right;
      int height = viewerPanel.getHeight() - insets.top - insets.bottom;
      if (d.width > width) {
        d.width = width;
      }
      if (d.height > height) {
        d.height = height;
      }
      dialogPanel.add(dialog, BorderLayout.CENTER);

      dialogPanel.setBounds(
          ((width - d.width) >> 1) + insets.left,
          ((height - d.height) >> 1) + insets.top,
          d.width + insets.left + insets.right,
          d.height + insets.top + insets.bottom);
      dialog.setVisible(true);
      layeredPane.add(dialogPanel, DIALOG_LAYER);
      currentDialog = dialog;
      mainPanel.repaint();
    }
  }
Exemplo n.º 13
0
    /**
     * Reinitialize the insets parameter with this Border's current Insets.
     *
     * @param c the component for which this border insets value applies
     * @param insets the object to be reinitialized
     */
    public Insets getBorderInsets(Component c, Insets insets) {
      Border border = getBorder();
      if (border != null) {
        if (border instanceof AbstractBorder) {
          ((AbstractBorder) border).getBorderInsets(c, insets);
        } else {
          // Can't reuse border insets because the Border interface
          // can't be enhanced.
          Insets i = border.getBorderInsets(c);
          insets.top = i.top;
          insets.right = i.right;
          insets.bottom = i.bottom;
          insets.left = i.left;
        }
      } else {
        insets.left = insets.top = insets.right = insets.bottom = 0;
      }

      insets.left += EDGE_SPACING + TEXT_SPACING;
      insets.right += EDGE_SPACING + TEXT_SPACING;
      insets.top += EDGE_SPACING + TEXT_SPACING;
      insets.bottom += EDGE_SPACING + TEXT_SPACING;

      if (c == null || label == null) {
        return insets;
      }

      insets.top += label.getHeight();

      return insets;
    }
 private void paintFocusAndRollover(Graphics2D g2, JComponent c, Color color) {
   g2.setPaint(
       new GradientPaint(
           0, 0, color, c.getWidth() - 1, c.getHeight() - 1, color.brighter(), true));
   g2.fill(shape);
   g2.setColor(c.getBackground());
   g2.fill(border);
 }
Exemplo n.º 15
0
  /** @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, javax.swing.JComponent) */
  public void update(Graphics g, JComponent c) {
    SeaGlassContext context = getContext(c);

    SeaGlassLookAndFeel.update(context, g);
    context.getPainter().paintTableBackground(context, g, 0, 0, c.getWidth(), c.getHeight());
    paint(context, g);
    context.dispose();
  }
Exemplo n.º 16
0
  /**
   * Notifies this UI delegate to repaint the specified component. This method paints the component
   * background, then calls the {@link #paint(SynthContext,Graphics)} method.
   *
   * <p>In general, this method does not need to be overridden by subclasses. All Look and Feel
   * rendering code should reside in the {@code paint} method.
   *
   * @param g the {@code Graphics} object used for painting
   * @param c the component being painted
   * @see #paint(SynthContext,Graphics)
   */
  @Override
  public void update(Graphics g, JComponent c) {
    SynthContext context = getContext(c);

    SynthLookAndFeel.update(context, g);
    context.getPainter().paintScrollPaneBackground(context, g, 0, 0, c.getWidth(), c.getHeight());
    paint(context, g);
  }
Exemplo n.º 17
0
  public static Rectangle2D getInteriorRect(JComponent c) {
    int x = getBorderSize(c);
    int y = getBorderSize(c);
    int w = c.getWidth() - (getBorderSize(c) * 2);
    int h = c.getHeight() - (getBorderSize(c) * 2);

    return new Rectangle2D.Double(x, y, w, h);
  }
Exemplo n.º 18
0
  private void repaintBadge(JComponent field) {
    Point p = field.getLocationOnScreen();
    SwingUtilities.convertPointFromScreen(p, this);

    int x = p.x - warningIcon.getWidth() / 2;
    int y = (int) (p.y + field.getHeight() - warningIcon.getHeight() / 1.5);

    repaint(x, y, warningIcon.getWidth(), warningIcon.getHeight());
  }
  private BufferedImage exportImageFromComponent(JComponent component) {
    BufferedImage image =
        new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
    Graphics gx = image.getGraphics();
    component.paint(gx);
    gx.dispose();

    return image;
  }
Exemplo n.º 20
0
  public static RoundRectangle2D getRoundedInteriorShape(JComponent c) {
    int x = getBorderSize(c);
    int y = getBorderSize(c);
    int w = c.getWidth() - (getBorderSize(c) * 2);
    int h = c.getHeight() - (getBorderSize(c) * 2);
    int roundCorner = getRoundedInteriorCorner(c);

    return new RoundRectangle2D.Double(x, y, w, h, roundCorner, roundCorner);
  }
Exemplo n.º 21
0
 @Override
 public void paint(Graphics g, JComponent c) {
   Gripper gripper = (Gripper) c;
   paintBackground(g, gripper);
   int state = gripper.isSelected() ? ThemePainter.STATE_SELECTED : ThemePainter.STATE_DEFAULT;
   if (_gripperPainter == null) {
     getPainter()
         .paintGripper(
             c,
             g,
             new Rectangle(0, 0, c.getWidth(), c.getHeight()),
             gripper.getOrientation(),
             state);
   } else {
     _gripperPainter.paint(
         c, g, new Rectangle(0, 0, c.getWidth(), c.getHeight()), gripper.getOrientation(), state);
   }
 }
Exemplo n.º 22
0
  public static RoundRectangle2D getRoundedExternalShape(JComponent c) {
    int x = 0;
    int y = 0;
    int w = c.getWidth();
    int h = c.getHeight();
    int roundCorner = getRoundedExteriorCorner(c);

    return new RoundRectangle2D.Double(x, y, w, h, roundCorner, roundCorner);
  }
Exemplo n.º 23
0
 public void paintBackground(Graphics g, JComponent c) {
   if (c.isOpaque()) {
     if (c.getBackground() instanceof ColorUIResource) {
       g.setColor(AbstractLookAndFeel.getBackgroundColor());
     } else {
       g.setColor(c.getBackground());
     }
     g.fillRect(0, 0, c.getWidth(), c.getHeight());
   }
 }
Exemplo n.º 24
0
 public void update(Graphics g, JComponent c) {
   if (c.isOpaque()) {
     g.setColor(c.getBackground());
     g.fillRect(0, 0, c.getWidth(), c.getHeight());
     if (isToolBarComboBox(c)) {
       c.setOpaque(false);
     }
   }
   paint(g, c);
 }
Exemplo n.º 25
0
  @Override
  public void update(Graphics g, JComponent c) {
    Point2D start = new Point2D.Float(0, 0);
    Point2D end = new Point2D.Float(0, c.getHeight());
    float[] dist = {0.0f, 1.0f};
    Color[] colors = SkinColors.APPLICATION_HEADER_GRADIENT_COLORS;
    LinearGradientPaint paint = new LinearGradientPaint(start, end, dist, colors);

    Graphics2D graphics = (Graphics2D) g.create();
    // optimization - do not call fillRect on graphics
    // with anti-alias turned on
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    graphics.setPaint(paint);
    graphics.fillRect(0, 0, c.getWidth(), c.getHeight());

    graphics.dispose();

    super.paint(g, c);
  }
Exemplo n.º 26
0
  public static RoundRectangle2D getExternalPaintableShape(JComponent c) {
    int x = 0, y = 0;
    int w = c.getWidth() - 1, h = c.getHeight() - 1;
    int roundCorner = h;
    Integer maxRoundCorner = (Integer) c.getClientProperty("maxRoundCorner");
    if (maxRoundCorner != null && maxRoundCorner >= 0) {
      roundCorner = Math.min(roundCorner, maxRoundCorner);
    }

    return new RoundRectangle2D.Double(x, y, w, h, roundCorner, roundCorner);
  }
Exemplo n.º 27
0
 public void paintBackground(Graphics g, JComponent c) {
   if (c.isOpaque()) {
     if ((c.getBackground().equals(AbstractLookAndFeel.getBackgroundColor()))
         && (c.getBackground() instanceof ColorUIResource)) {
       HiFiUtils.fillComponent(g, c);
     } else {
       g.setColor(c.getBackground());
       g.fillRect(0, 0, c.getWidth(), c.getHeight());
     }
   }
 }
  public void paintBackground(Graphics g, JComponent c) {
    int menuWidth = c.getWidth();
    int menuHeight = c.getHeight();
    PlastikColorTheme colorTheme = PlastikLookAndFeel.getTheme().getColorTheme();

    Color oldColor = g.getColor();
    g.setColor(colorTheme.getColor(PlastikColorTheme.POPUP_MENU | PlastikColorTheme.BACKGROUND));
    g.fillRect(0, 0, menuWidth, menuHeight);

    g.setColor(oldColor);
  }
Exemplo n.º 29
0
 protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
   int w = c.getWidth();
   int h = c.getHeight();
   if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
     JTattooUtilities.fillVerGradient(
         g, AbstractLookAndFeel.getTheme().getTrackColors(), 0, 0, w, h);
   } else {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getTrackColors(), 0, 0, w, h);
   }
 }
  @Override
  public void update(Graphics g, JComponent c) {
    SeaGlassContext context = getContext(c);

    SeaGlassLookAndFeel.update(context, g);
    context
        .getPainter()
        .paintToolBarBackground(
            context, g, 0, 0, c.getWidth(), c.getHeight(), toolBar.getOrientation());
    paint(context, g);
    context.dispose();
  }