@Override
 protected void paintImage(
     Component c, Graphics g, int x, int y, int imageW, int imageH, Image image, Object[] args) {
   g.translate(x, y);
   g.drawImage(image, 0, 0, null);
   g.translate(-x, -y);
 }
  @Override
  public void paint(Graphics g) {
    Color origColor;
    boolean isPressed, isEnabled;
    int w, h, size;

    w = getSize().width;
    h = getSize().height;
    origColor = g.getColor();
    isPressed = getModel().isPressed();
    isEnabled = isEnabled();

    g.setColor(getBackground());
    g.fillRect(1, 1, w - 2, h - 2);

    /// Draw the proper Border
    if (getBorder() != null && !(getBorder() instanceof UIResource)) {
      paintBorder(g);
    } else if (isPressed) {
      g.setColor(shadow);
      g.drawRect(0, 0, w - 1, h - 1);
    } else {
      // Using the background color set above
      g.drawLine(0, 0, 0, h - 1);
      g.drawLine(1, 0, w - 2, 0);

      g.setColor(highlight); // inner 3D border
      g.drawLine(1, 1, 1, h - 3);
      g.drawLine(2, 1, w - 3, 1);

      g.setColor(shadow); // inner 3D border
      g.drawLine(1, h - 2, w - 2, h - 2);
      g.drawLine(w - 2, 1, w - 2, h - 3);

      //                g.setColor(darkShadow);     // black drop shadow  __|
      g.drawLine(0, h - 1, w - 1, h - 1);
      g.drawLine(w - 1, h - 1, w - 1, 0);
    }

    // If there's no room to draw arrow, bail
    if (h < 5 || w < 5) {
      g.setColor(origColor);
      return;
    }

    if (isPressed) {
      g.translate(1, 1);
    }

    // Draw the arrow
    size = Math.min((h - 4) / 3, (w - 4) / 3);
    size = Math.max(size, 4); // Customized
    paintTriangle(g, (w - size) / 2, (h - size) / 2, size, direction, isEnabled);

    // Reset the Graphics back to it's original settings
    if (isPressed) {
      g.translate(-1, -1);
    }
    g.setColor(origColor);
  }
Ejemplo n.º 3
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {

      Color shadow = UIManager.getColor("controlShadow");
      if (shadow == null) {
        shadow = Color.GRAY;
      }
      Color lightShadow = new Color(shadow.getRed(), shadow.getGreen(), shadow.getBlue(), 170);
      Color lighterShadow = new Color(shadow.getRed(), shadow.getGreen(), shadow.getBlue(), 70);
      g.translate(x, y);

      g.setColor(shadow);
      g.fillRect(0, 0, w - 3, 1);
      g.fillRect(0, 0, 1, h - 3);
      g.fillRect(w - 3, 1, 1, h - 3);
      g.fillRect(1, h - 3, w - 3, 1);
      // Shadow line 1
      g.setColor(lightShadow);
      g.fillRect(w - 3, 0, 1, 1);
      g.fillRect(0, h - 3, 1, 1);
      g.fillRect(w - 2, 1, 1, h - 3);
      g.fillRect(1, h - 2, w - 3, 1);
      // Shadow line2
      g.setColor(lighterShadow);
      g.fillRect(w - 2, 0, 1, 1);
      g.fillRect(0, h - 2, 1, 1);
      g.fillRect(w - 2, h - 2, 1, 1);
      g.fillRect(w - 1, 1, 1, h - 2);
      g.fillRect(1, h - 1, w - 2, 1);
      g.translate(-x, -y);
    }
Ejemplo n.º 4
0
  /**
   * Draws a simple 3d border for the given component.
   *
   * @param c The component to draw its border.
   * @param g The graphics context.
   * @param x The x coordinate of the top left corner.
   * @param y The y coordinate of the top left corner.
   * @param w The width.
   * @param h The height.
   */
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    boolean isHorizontal = ((JToolBar) c).getOrientation() == HORIZONTAL;

    g.setColor(MetouiaLookAndFeel.getControlHighlight());
    if (isHorizontal) {
      g.drawLine(0, 0, w - 1, 0);
    } else {
      g.drawLine(0, 0, 0, h - 1);
    }

    g.setColor(MetouiaLookAndFeel.getControlShadow());
    if (isHorizontal) {
      g.drawLine(0, h - 1, w - 1, h - 1);
    } else {
      g.drawLine(w - 1, 0, w - 1, h - 1);
    }

    g.translate(x, y);

    if (((JToolBar) c).isFloatable()) {
      if (((JToolBar) c).getOrientation() == HORIZONTAL) {
        dots.setDotsArea(5, c.getSize().height - 4);
        if (c.getComponentOrientation().isLeftToRight()) {
          dots.paintIcon(c, g, 2, 2);
        } else {
          dots.paintIcon(c, g, c.getBounds().width - 12, 2);
        }
      } else {
        dots.setDotsArea(c.getSize().width - 4, 5);
        dots.paintIcon(c, g, 2, 2);
      }
    }

    g.translate(-x, -y);
  }
    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);
    }
 public void paint(Graphics g, JComponent c) {
   JTree tree = (JTree) c;
   TreeModel mod = tree.getModel();
   g.translate(10, 10);
   paintRecursive(g, 0, 0, 0, 0, tree, mod, mod.getRoot());
   g.translate(-10, -10);
 }
  // draw determinate
  private void drawXpHorzProgress(Graphics g, int x, int y, int w, int h, int amountFull) {
    g.translate(x, y);

    // paint the track
    if (!progressBar.isOpaque()) {
      g.setColor(progressBar.getBackground());
      g.fillRect(0, 0, w, h);
    }

    ProgressKey key = new ProgressKey(progressBar.getForeground(), true, h);
    Object value = cache.get(key);

    if (value == null) {
      // create new image
      Image img = new BufferedImage(6, h, BufferedImage.TYPE_INT_ARGB);
      Graphics imgGraphics = img.getGraphics();

      // draw into image graphics
      Color c = progressBar.getForeground();
      Color c2 = ColorRoutines.lighten(c, 15);
      Color c3 = ColorRoutines.lighten(c, 35);
      Color c4 = ColorRoutines.lighten(c, 60);

      imgGraphics.setColor(c4);
      imgGraphics.drawLine(0, 0, 5, 0);
      imgGraphics.drawLine(0, h - 1, 5, h - 1);

      imgGraphics.setColor(c3);
      imgGraphics.drawLine(0, 1, 5, 1);
      imgGraphics.drawLine(0, h - 2, 5, h - 2);

      imgGraphics.setColor(c2);
      imgGraphics.drawLine(0, 2, 5, 2);
      imgGraphics.drawLine(0, h - 3, 5, h - 3);

      imgGraphics.setColor(c);
      imgGraphics.fillRect(0, 3, 6, h - 6);

      // dispose of image graphics
      imgGraphics.dispose();

      cache.put(key, img);
      value = img;
    }

    int mx = 0;

    while (mx < amountFull) {
      if (mx + 6 > w) {
        // paint partially
        g.drawImage((Image) value, mx, 0, w - mx, h, progressBar);
      } else {
        g.drawImage((Image) value, mx, 0, progressBar);
      }

      mx += 8;
    }

    g.translate(-x, -y);
  }
Ejemplo n.º 8
0
    @Override
    public void paintComponent(Graphics g) {
      Graphics g2 = g.create();

      Dimension d = getSize();
      CPArtwork artwork = controller.getArtwork();
      Object[] layers = artwork.getLayers();

      g2.setColor(new Color(0x606060));
      g2.fillRect(0, 0, d.width, d.height - layers.length * layerH);

      g2.setColor(Color.black);
      g2.translate(0, d.height - layerH);
      for (int i = 0; i < layers.length; i++) {
        drawLayer(g2, (CPLayer) layers[i], i == artwork.getActiveLayerNb());
        g2.translate(0, -layerH);
      }

      if (layerDragReally) {
        g2.translate(0, layers.length * layerH - (d.height - layerH));
        g2.drawRect(0, layerDragY - layerH / 2, d.width, layerH);

        int layerOver = (d.height - layerDragY) / layerH;
        if (layerOver <= layers.length
            && layerOver != layerDragNb
            && layerOver != layerDragNb + 1) {
          g2.fillRect(0, d.height - layerOver * layerH - 2, d.width, 4);
        }
      }
    }
Ejemplo n.º 9
0
    public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
      Color color = c == null ? Color.GRAY : c.getBackground();
      // In a compound sort, make each succesive triangle 20%
      // smaller than the previous one.
      int dx = (int) (size / 2 * Math.pow(0.8, priority));
      int dy = descending ? dx : -dx;
      // Align icon (roughly) with font baseline.
      y = y + 5 * size / 6 + (descending ? -dy : 0);
      int shift = descending ? 1 : -1;
      g.translate(x, y);

      // Right diagonal.
      g.setColor(color.darker());
      g.drawLine(dx / 2, dy, 0, 0);
      g.drawLine(dx / 2, dy + shift, 0, shift);

      // Left diagonal.
      g.setColor(color.brighter());
      g.drawLine(dx / 2, dy, dx, 0);
      g.drawLine(dx / 2, dy + shift, dx, shift);

      // Horizontal line.
      if (descending) {
        g.setColor(color.darker().darker());
      } else {
        g.setColor(color.brighter().brighter());
      }
      g.drawLine(dx, 0, 0, 0);

      g.setColor(color);
      g.translate(-x, -y);
    }
Ejemplo n.º 10
0
  private void paintBase(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Direction facing = painter.getAttributeValue(StdAttr.FACING);
    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    g.translate(x, y);
    double rotate = 0.0;
    if (facing != null && facing != Direction.EAST && g instanceof Graphics2D) {
      rotate = -facing.toRadians();
      ((Graphics2D) g).rotate(rotate);
    }

    Object shape = painter.getGateShape();
    if (shape == AppPreferences.SHAPE_RECTANGULAR) {
      paintRectangularBase(g, painter);
    } else if (shape == AppPreferences.SHAPE_DIN40700) {
      int width = painter.getAttributeValue(ATTR_SIZE) == SIZE_NARROW ? 20 : 30;
      PainterDin.paintAnd(painter, width, 18, true);
    } else {
      PainterShaped.paintNot(painter);
    }

    if (rotate != 0.0) {
      ((Graphics2D) g).rotate(-rotate);
    }
    g.translate(-x, -y);
  }
 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);
   }
 }
 @Override
 protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
   int shift = isMirrored() ? -9 : 9;
   g.translate(shift, 0);
   super.paintThumb(g, c, thumbBounds);
   g.translate(-shift, 0);
 }
Ejemplo n.º 13
0
  protected void drawArrow(Graphics g) {
    this.dimension = getSize();

    if (getModel().isEnabled()) {
      g.setColor(RapidLookTools.getColors().getSpinnerColors()[9]);
    } else {
      g.setColor(RapidLookTools.getColors().getSpinnerColors()[10]);
    }

    int baseY = (int) ((this.dimension.getHeight() / 2) - 2);
    if (!this.up) {
      baseY++;
    }

    g.translate(5, baseY);
    if (this.up) {
      g.drawLine(2, 0, 3, 0);
      g.drawLine(1, 1, 4, 1);
      g.drawLine(0, 2, 1, 2);
      g.drawLine(4, 2, 5, 2);
    } else {
      g.drawLine(2, 2, 3, 2);
      g.drawLine(1, 1, 4, 1);
      g.drawLine(0, 0, 1, 0);
      g.drawLine(4, 0, 5, 0);
    }
    g.translate(-6, -baseY);
  }
 private static void drawSelection(JTable table, int column, Graphics g, final int width) {
   int y = 0;
   final int[] rows = table.getSelectedRows();
   final int height = table.getRowHeight();
   for (int row : rows) {
     final TableCellRenderer renderer = table.getCellRenderer(row, column);
     final Component component =
         renderer.getTableCellRendererComponent(
             table, table.getValueAt(row, column), false, false, row, column);
     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);
   }
 }
Ejemplo n.º 15
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);
    }
Ejemplo n.º 16
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      g.translate(x, y);

      if (((JToolBar) c).isFloatable()) {
        if (((JToolBar) c).getOrientation() == HORIZONTAL) {
          int shift = MetalLookAndFeel.usingOcean() ? -1 : 0;
          bumps.setBumpArea(10, h - 4);
          if (MetalUtils.isLeftToRight(c)) {
            bumps.paintIcon(c, g, 2, 2 + shift);
          } else {
            bumps.paintIcon(c, g, w - 12, 2 + shift);
          }
        } else // vertical
        {
          bumps.setBumpArea(w - 4, 10);
          bumps.paintIcon(c, g, 2, 2);
        }
      }

      if (((JToolBar) c).getOrientation() == HORIZONTAL && MetalLookAndFeel.usingOcean()) {
        g.setColor(MetalLookAndFeel.getControl());
        g.drawLine(0, h - 2, w, h - 2);
        g.setColor(UIManager.getColor("ToolBar.borderColor"));
        g.drawLine(0, h - 1, w, h - 1);
      }

      g.translate(-x, -y);
    }
Ejemplo n.º 17
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      JMenuItem b = (JMenuItem) c;
      ButtonModel model = b.getModel();

      g.translate(x, y);

      if (c.getParent() instanceof JMenuBar) {
        if (model.isArmed() || model.isSelected()) {
          g.setColor(MetalLookAndFeel.getControlDarkShadow());
          g.drawLine(0, 0, w - 2, 0);
          g.drawLine(0, 0, 0, h - 1);
          g.drawLine(w - 2, 2, w - 2, h - 1);

          g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
          g.drawLine(w - 1, 1, w - 1, h - 1);

          g.setColor(MetalLookAndFeel.getMenuBackground());
          g.drawLine(w - 1, 0, w - 1, 0);
        }
      } else {
        if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
          g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
          g.drawLine(0, 0, w - 1, 0);

          g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
          g.drawLine(0, h - 1, w - 1, h - 1);
        } else {
          g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
          g.drawLine(0, 0, 0, h - 1);
        }
      }

      g.translate(-x, -y);
    }
Ejemplo n.º 18
0
  /**
   * Prints the specified page on the specified graphics using <code>pageForm</code> for the page
   * format.
   *
   * @param g The graphics to paint the graph on.
   * @param printFormat The page format to use for printing.
   * @param page The page to print
   * @return Returns {@link Printable#PAGE_EXISTS} or {@link Printable#NO_SUCH_PAGE}.
   */
  public int print(Graphics g, PageFormat printFormat, int page) {
    Dimension pSize = graph.getPreferredSize();
    int w = (int) (printFormat.getWidth() * pageScale);
    int h = (int) (printFormat.getHeight() * pageScale);
    int cols = (int) Math.max(Math.ceil((double) (pSize.width - 5) / (double) w), 1);
    int rows = (int) Math.max(Math.ceil((double) (pSize.height - 5) / (double) h), 1);
    if (page < cols * rows) {

      // Configures graph for printing
      RepaintManager currentManager = RepaintManager.currentManager(this);
      currentManager.setDoubleBufferingEnabled(false);
      double oldScale = getGraph().getScale();
      getGraph().setScale(1 / pageScale);
      int dx = (int) ((page % cols) * printFormat.getWidth());
      int dy = (int) ((page % rows) * printFormat.getHeight());
      g.translate(-dx, -dy);
      g.setClip(dx, dy, (int) (dx + printFormat.getWidth()), (int) (dy + printFormat.getHeight()));

      // Prints the graph on the graphics.
      getGraph().paint(g);

      // Restores graph
      g.translate(dx, dy);
      graph.setScale(oldScale);
      currentManager.setDoubleBufferingEnabled(true);
      return PAGE_EXISTS;
    } else {
      return NO_SUCH_PAGE;
    }
  }
  // documentation inherited
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2 = (Graphics2D) g;

    // center the tile display if we are bigger than we need to be
    g.translate(_tx, _ty);

    //         // paint coordinates in the grid that contains our tiles
    //         for (int yy = 0; yy < _height; yy++) {
    //             for (int xx = 0; xx < _width; xx++) {
    //                 int cx = xx*TILE_WIDTH, cy = yy*TILE_HEIGHT;
    //                 g.drawRect(cx, cy, TILE_WIDTH, TILE_HEIGHT);
    //                 String coord = (xx-_origX) + "/" + (yy-_origY);
    //                 g.drawString(coord, cx+TILE_WIDTH/2, cy+TILE_HEIGHT/2);
    //             }
    //         }

    // iterate over our tiles, painting each of them
    for (AtlantiTile tile : _tiles) {
      tile.paint(g2, _origX, _origY);
    }

    // if we have a placing tile, draw that one as well
    if (_placingTile != null && _validPlacement) {
      // if the current position is valid, draw the placing tile
      _placingTile.paint(g2, _origX, _origY);

      // draw a green rectangle around the placing tile
      g.setColor(Color.blue);
      int sx = (_placingTile.x + _origX) * TILE_WIDTH;
      int sy = (_placingTile.y + _origY) * TILE_HEIGHT;
      g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1);
    }

    // if we have a recently placed tile, draw that one as well
    if (_placedTile != null) {
      // draw the tile
      _placedTile.paint(g2, _origX, _origY);

      // draw a white rectangle around the placed tile
      g.setColor(Color.white);
      int sx = (_placedTile.x + _origX) * TILE_WIDTH;
      int sy = (_placedTile.y + _origY) * TILE_HEIGHT;
      g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1);
    }

    // draw a white rectangle around the last placed
    if (_lastPlacedTile != null) {
      g.setColor(Color.white);
      int sx = (_lastPlacedTile.x + _origX) * TILE_WIDTH;
      int sy = (_lastPlacedTile.y + _origY) * TILE_HEIGHT;
      g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1);
    }

    // undo our translations
    g.translate(-_tx, -_ty);
  }
Ejemplo n.º 20
0
  @Override
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    JComponent popup = (JComponent) c;
    g.translate(x, y);
    try {
      this.bottomLeft = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_LEFT_PIC);
      if (this.bottomLeft != null) {
        g.drawImage(this.bottomLeft, 0, h - 5, c);
      }

      this.bottomRight = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_RIGHT_PIC);
      if (this.bottomRight != null) {
        g.drawImage(this.bottomRight, w - 5, h - 5, c);
      }

      this.right = (Image) popup.getClientProperty(RoundedPopupFactory.RIGHT_PIC);
      if (this.right != null) {
        g.drawImage(this.right, w - 1, 0, c);
      }

      this.bottom = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_PIC);
      if (this.bottom != null) {
        g.drawImage(this.bottom, 5, h - 1, c);
      }
    } catch (Exception exp) {
      // do nothing
    }

    if (ShadowedPopupMenuBorder.POPUP_BOTTOM_LEFT != null)
      g.drawImage(ShadowedPopupMenuBorder.POPUP_BOTTOM_LEFT, 0, h - 5, popup);
    if (ShadowedPopupMenuBorder.POPUP_BOTTOM_RIGHT != null)
      g.drawImage(ShadowedPopupMenuBorder.POPUP_BOTTOM_RIGHT, w - 5, h - 5, popup);

    ColorUIResource c1 = new ColorUIResource(150, 150, 150);
    Color c4 = new Color(160, 160, 160, 100);
    ColorUIResource c2 = new ColorUIResource(135, 135, 135);

    g.setColor(UIManager.getColor("MenuItem.background"));
    g.drawLine(1, 0, w - 4, 0);
    g.drawLine(1, 1, w - 4, 1);
    g.drawLine(1, 0, 1, h - 7);
    g.drawLine(5, h - 3, w - 6, h - 3);
    g.setColor(UIManager.getColor("MenuItem.fadingColor"));
    g.drawLine(w - 3, 2, w - 3, h - 5);

    g.setColor(c1);
    g.drawLine(0, 0, 0, h - 6);
    g.setColor(c4);
    g.drawLine(5, h - 1, w - 6, h - 1);
    g.drawLine(w - 1, 2, w - 1, h - 6);

    g.setColor(c2);
    g.drawLine(w - 2, 0, w - 2, h - 6);
    g.drawLine(5, h - 2, w - 6, h - 2);

    g.translate(-x, -y);
  }
Ejemplo n.º 21
0
 private static void drawPressed3DBorder(
     final Graphics g, final int x, final int y, final int w, final int h) {
   g.translate(x, y);
   drawFlush3DBorder(g, 0, 0, w, h);
   g.setColor(MetalLookAndFeel.getControlShadow());
   g.drawLine(1, 1, 1, h - 2);
   g.drawLine(1, 1, w - 2, 1);
   g.translate(-x, -y);
 }
Ejemplo n.º 22
0
 static void drawDefaultButtonBorder(Graphics g, int x, int y, int w, int h, boolean active) {
   drawButtonBorder(g, x + 1, y + 1, w - 1, h - 1, active);
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlDarkShadow());
   g.drawRect(0, 0, w - 3, h - 3);
   g.drawLine(w - 2, 0, w - 2, 0);
   g.drawLine(0, h - 2, 0, h - 2);
   g.translate(-x, -y);
 }
Ejemplo n.º 23
0
 // Helper method utilized by the CheckBoxIcon and the CheckBoxMenuItemIcon.
 private static void drawCheck(Graphics g, int x, int y) {
   g.translate(x, y);
   g.drawLine(3, 5, 3, 5);
   g.fillRect(3, 6, 2, 2);
   g.drawLine(4, 8, 9, 3);
   g.drawLine(5, 8, 9, 4);
   g.drawLine(5, 9, 9, 5);
   g.translate(-x, -y);
 }
    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);
    }
Ejemplo n.º 25
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {

      g.translate(x, y);
      g.setColor(UIManager.getColor("controlLtHighlight"));
      g.fillRect(0, 0, w, 1);
      g.fillRect(0, 1, 1, h - 1);
      g.setColor(UIManager.getColor("controlShadow"));
      g.fillRect(0, h - 1, w, 1);
      g.translate(-x, -y);
    }
Ejemplo n.º 26
0
 @Override
 protected void paintComponent(Graphics g) {
   if (Option == LEFT_TO_RIGHT) {
     g.translate((int) ((System.currentTimeMillis() / Speed) % (getWidth() * 2) - getWidth()), 0);
   } else if (Option == RIGHT_TO_LEFT) {
     g.translate((int) (getWidth() - (System.currentTimeMillis() / Speed) % (getWidth() * 2)), 0);
   }
   super.paintComponent(g);
   repaint(5);
 }
Ejemplo n.º 27
0
  /**
   * Called to draw the panel.
   *
   * @param g Graphics device to draw the panel to.
   */
  public void paintComponent(Graphics g) {
    final Point scrollPosition = getScrollPosition();
    g.translate(-scrollPosition.x, -scrollPosition.y);

    try {
      super.paintComponent(g);
    } finally {
      g.translate(scrollPosition.x, scrollPosition.y);
    }
  }
  // draw indeterminate
  private void drawXpVertProgress(Graphics g, int x, int y, int w, int h, Rectangle boxRect) {
    // paint the track
    if (!progressBar.isOpaque()) {
      g.setColor(progressBar.getBackground());
      g.fillRect(x, y, w, h);
    }

    g.translate(boxRect.x, boxRect.y);

    ProgressKey key = new ProgressKey(progressBar.getForeground(), false, w);
    Object value = cache.get(key);

    if (value == null) {
      // create new image
      Image img = new BufferedImage(w, 6, BufferedImage.TYPE_INT_ARGB);
      Graphics imgGraphics = img.getGraphics();

      // draw into image graphics
      Color c = progressBar.getForeground();
      Color c2 = ColorRoutines.lighten(c, 15);
      Color c3 = ColorRoutines.lighten(c, 35);
      Color c4 = ColorRoutines.lighten(c, 60);

      imgGraphics.setColor(c4);
      imgGraphics.drawLine(0, 0, 0, 5);
      imgGraphics.drawLine(w - 1, 0, w - 1, 5);

      imgGraphics.setColor(c3);
      imgGraphics.drawLine(1, 0, 1, 5);
      imgGraphics.drawLine(w - 2, 0, w - 2, 5);

      imgGraphics.setColor(c2);
      imgGraphics.drawLine(2, 0, 2, 5);
      imgGraphics.drawLine(w - 3, 0, w - 3, 5);

      imgGraphics.setColor(c);
      imgGraphics.fillRect(3, 0, w - 6, 6);

      // dispose of image graphics
      imgGraphics.dispose();

      cache.put(key, img);
      value = img;
    }

    int my = 0;

    while (my + 6 < boxRect.height) {
      g.drawImage((Image) value, 0, my, progressBar);

      my += 8;
    }

    g.translate(-boxRect.x, -boxRect.y);
  }
  /** Paints the track. */
  @Override
  public void paintTrack(Graphics g) {
    // Draw track.
    super.paintTrack(g);

    Rectangle trackBounds = trackRect;

    if (slider.getOrientation() == JSlider.HORIZONTAL) {
      // Determine position of selected range by moving from the middle
      // of one thumb to the other.
      int lowerX = thumbRect.x + (thumbRect.width / 2);
      int upperX = upperThumbRect.x + (upperThumbRect.width / 2);

      // Determine track position.
      int cy = (trackBounds.height / 2) - 2;

      // Save color and shift position.
      Color oldColor = g.getColor();
      g.translate(trackBounds.x, trackBounds.y + cy);

      // Draw selected range.
      g.setColor(rangeColor);
      for (int y = 0; y <= 3; y++) {
        g.drawLine(lowerX - trackBounds.x, y, upperX - trackBounds.x, y);
      }

      // Restore position and color.
      g.translate(-trackBounds.x, -(trackBounds.y + cy));
      g.setColor(oldColor);

    } else {
      // Determine position of selected range by moving from the middle
      // of one thumb to the other.
      int lowerY = thumbRect.x + (thumbRect.width / 2);
      int upperY = upperThumbRect.x + (upperThumbRect.width / 2);

      // Determine track position.
      int cx = (trackBounds.width / 2) - 2;

      // Save color and shift position.
      Color oldColor = g.getColor();
      g.translate(trackBounds.x + cx, trackBounds.y);

      // Draw selected range.
      g.setColor(rangeColor);
      for (int x = 0; x <= 3; x++) {
        g.drawLine(x, lowerY - trackBounds.y, x, upperY - trackBounds.y);
      }

      // Restore position and color.
      g.translate(-(trackBounds.x + cx), -trackBounds.y);
      g.setColor(oldColor);
    }
  }
 @Override
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   g.translate(x, y);
   g.setColor(new ColorUIResource(190, 190, 190));
   g.drawLine(0, 0, w - 1, 0);
   g.drawLine(0, 0, 0, h - 1);
   g.setColor(new ColorUIResource(220, 220, 220));
   g.drawLine(w - 1, 1, w - 1, h - 1);
   g.drawLine(1, h - 1, w - 1, h - 1);
   g.translate(-x, -y);
 }