@Override
 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
   g.setColor(new Color(0, 0, 255, 50));
   g.fillRoundRect(x, y, width, height, 10, 10);
   g.setColor(Color.white);
   g.drawRoundRect(x + 2, y + 2, width - 4, height - 4, 10, 10);
 }
 public Image getScreenshot() {
   BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
   Graphics g = image.getGraphics();
   paint(g);
   g.dispose();
   return image;
 }
示例#3
0
  // ------------------------------------------------------------------------
  // SCREEN PAINTER
  // Put some function here to paint whatever you want over the screen before and after
  // all edges and nodes have been painted.
  public void PaintScreenBefore(Graphics g) {

    Dimension d = MainClass.mainFrame.GetGraphDisplayPanel().getSize();
    NodeInfo nodeInfo;
    int x = 0;
    int y = 0;
    int step = 10;

    for (; x < d.width; x += step) {
      for (y = 0; y < d.height; y += step) {
        double val = 0;
        double sum = 0;
        double total = 0;
        double min = 10000000;
        for (Enumeration nodes = proprietaryNodeInfo.elements(); nodes.hasMoreElements(); ) {
          nodeInfo = (NodeInfo) nodes.nextElement();
          double dist = distance(x, y, nodeInfo.centerX, nodeInfo.centerY);
          if (nodeInfo.value != -1 && nodeInfo.nodeNumber.intValue() != 1) { // 121
            if (dist < min) min = dist;
            val += ((double) nodeInfo.value) / dist / dist;
            sum += (1 / dist / dist);
          }
        }
        int reading = (int) (val / sum);
        reading = reading >> 2;
        if (reading > 255) reading = 255;
        g.setColor(new Color(reading, reading, reading));
        g.fillRect(x, y, step, step);
      }
    }
  }
示例#4
0
 public void paintThumb(Graphics g) {
   Icon icon = null;
   if (slider.getOrientation() == JSlider.HORIZONTAL) {
     if (isRollover && slider.isEnabled()) {
       icon = getThumbHorIconRollover();
     } else {
       icon = getThumbHorIcon();
     }
   } else {
     if (isRollover && slider.isEnabled()) {
       icon = getThumbVerIconRollover();
     } else {
       icon = getThumbVerIcon();
     }
   }
   Graphics2D g2D = (Graphics2D) g;
   Composite savedComposite = g2D.getComposite();
   if (!slider.isEnabled()) {
     g.setColor(AbstractLookAndFeel.getBackgroundColor());
     g.fillRect(thumbRect.x + 1, thumbRect.y + 1, thumbRect.width - 2, thumbRect.height - 2);
     AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
     g2D.setComposite(alpha);
   }
   icon.paintIcon(null, g, thumbRect.x, thumbRect.y);
   g2D.setComposite(savedComposite);
 }
示例#5
0
  /** Overrides <code>Graphics.drawImage</code>. */
  public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info.log(toShortString() + " Drawing image: " + img + " at: " + new Point(x, y));
    }

    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawImage(img, x, y, observer);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      int i, count = (info.flashCount * 2) - 1;
      ImageProducer oldProducer = img.getSource();
      ImageProducer newProducer =
          new FilteredImageSource(oldProducer, new DebugGraphicsFilter(info.flashColor));
      Image newImage = Toolkit.getDefaultToolkit().createImage(newProducer);
      DebugGraphicsObserver imageObserver = new DebugGraphicsObserver();

      Image imageToDraw;
      for (i = 0; i < count; i++) {
        imageToDraw = (i % 2) == 0 ? newImage : img;
        loadImage(imageToDraw);
        graphics.drawImage(imageToDraw, x, y, imageObserver);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
    }
    return graphics.drawImage(img, x, y, observer);
  }
示例#6
0
 public void paintComponent(Graphics g) {
   g.setColor(new Color(0x8090ff));
   g.fillRect(0, 0, level.length * 16, level.height * 16);
   levelRenderer.render(g, 0);
   g.setColor(Color.BLACK);
   g.drawRect(xTile * 16 - 1, yTile * 16 - 1, 17, 17);
 }
    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 render(Graphics g) {
   g.setColor(color);
   g.fillRect(position.x, position.y, size.x, size.y);
   for (UIComponent component : components) {
     component.render(g);
   }
 }
示例#9
0
 @Override
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   g.setColor(color);
   g.drawLine(0, 0, getWidth(), getHeight());
   g.drawLine(getWidth(), 0, 0, getHeight());
 }
示例#10
0
 protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   if (c.getParent() instanceof JMenuBar) {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
       g.fillRect(x, y, w, h);
     }
   } else {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
       g.fillRect(x, y, w, h);
     } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) {
       Graphics2D g2D = (Graphics2D) g;
       Composite composite = g2D.getComposite();
       AlphaComposite alpha =
           AlphaComposite.getInstance(
               AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
       g2D.setComposite(alpha);
       g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
       g.fillRect(x, y, w, h);
       g2D.setComposite(composite);
     } else {
       g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
       g.fillRect(x, y, w, h);
     }
   }
   if (menuItem.isSelected() && menuItem.isArmed()) {
     g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
   }
 }
示例#11
0
 // Give the string and horizontal and verical offsets so that the label is
 // drawn in the center.
 public void drawLabel(Graphics g, String label, int hoffset, int voffset) {
   g.setColor(Color.black);
   int pixelsPerNm = DrawPanel.PIXELS_PER_NM;
   int xint = (int) Math.round(pixelsPerNm * z);
   int yint = (int) Math.round(pixelsPerNm * y);
   g.drawString(label, xint - hoffset, yint + voffset);
 }
 public void paint(Graphics g) {
   g.drawRect(x[0], y[0], 40, 40);
   g.fillRect(x[1], y[1], 20, 20);
   g.drawLine(x[2], y[2], x[3], y[3]);
   g.drawOval(x[4], y[4], 20, 30);
   g.drawString("Moveing", x[5], y[5]);
 }
示例#13
0
 public void drawTo(Graphics g, Line line) {
   if (!calc.tileOnMap(t1) || !calc.tileOnMap(t2)) return;
   if (calc.tileOnMap(line.getTile1()) && calc.tileOnMap(line.getTile2())) {
     Point p1 = calc.tileToMinimap(t1);
     Point p2 = calc.tileToMinimap(t2);
     Point p3 = calc.tileToMinimap(line.getTile2());
     Point p4 = calc.tileToMinimap(line.getTile1());
     GeneralPath path = new GeneralPath();
     path.moveTo(p1.x, p1.y);
     path.lineTo(p2.x, p2.y);
     path.lineTo(p3.x, p3.y);
     path.lineTo(p4.x, p4.y);
     path.closePath();
     g.setColor(POLY_FILL);
     ((Graphics2D) g).fill(path);
     ((Graphics2D) g).draw(path);
   }
   Point last = null, p;
   g.setColor(Color.ORANGE);
   for (RSTile t : pathList) {
     if (calc.tileOnMap(t)) {
       p = calc.tileToMinimap(t);
       g.fillOval(p.x - 2, p.y - 2, 5, 5);
       if (last != null) g.drawLine(p.x, p.y, last.x, last.y);
       last = p;
     } else last = null;
   }
 }
 public void draw(Graphics g) {
   Color oldColor = g.getColor();
   g.setColor(color);
   if (filled) g.fillRect(cornerX, cornerY, width, height);
   else g.drawRect(cornerX, cornerY, width, height);
   g.setColor(oldColor);
 }
示例#15
0
    @Override
    protected void paintComponent(Graphics g) {
      g.setColor(getBackground());
      g.fillRect(0, 0, getWidth(), getHeight());

      final String text = getText();
      final int len = text.length();
      int x;
      if (centerText) {
        x = (getWidth() - widthOfW * len) / 2 + 1;
      } else {
        x = 5;
      }
      int y = (getHeight() - fontHeight) / 2 + fontAscent;

      Graphics2D g2d = (Graphics2D) g;
      Object oldHints = null;
      if (desktopAAHints != null) {
        oldHints = g2d.getRenderingHints();
        g2d.addRenderingHints(desktopAAHints);
      }

      g.setColor(getForeground());
      g2d.drawString(text, x, y);

      // Restore rendering hints appropriately.
      if (desktopAAHints != null) {
        g2d.addRenderingHints((Map) oldHints);
      }

      // separator
      g.setColor(Color.GRAY);
      g.drawLine(0, 0, 0, getHeight());
    }
 public void draw(Graphics g) {
   Rectangle r = displayBox();
   g.setColor(Color.yellow);
   g.fillOval(r.x, r.y, r.width, r.height);
   g.setColor(Color.black);
   g.drawOval(r.x, r.y, r.width, r.height);
 }
  public void paintPalette(Graphics g) {
    boolean leftToRight = MetalUtils.isLeftToRight(frame);

    int width = getWidth();
    int height = getHeight();

    if (paletteBumps == null) {
      paletteBumps =
          new MetalBumps(
              0,
              0,
              MetalLookAndFeel.getPrimaryControlHighlight(),
              MetalLookAndFeel.getPrimaryControlInfo(),
              MetalLookAndFeel.getPrimaryControlShadow());
    }

    Color background = MetalLookAndFeel.getPrimaryControlShadow();
    Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();

    g.setColor(background);
    g.fillRect(0, 0, width, height);

    g.setColor(darkShadow);
    g.drawLine(0, height - 1, width, height - 1);

    int xOffset = leftToRight ? 4 : buttonsWidth + 4;
    int bumpLength = width - buttonsWidth - 2 * 4;
    int bumpHeight = getHeight() - 4;
    paletteBumps.setBumpArea(bumpLength, bumpHeight);
    paletteBumps.paintIcon(this, g, xOffset, 2);
  }
示例#18
0
  public void draw(Graphics g) {
    animate();

    g.setColor(Color.black);
    g.fillRect(0, 0, dim.width, dim.height);
    g.setColor(Color.white);

    numpaint++;
    DebugPrinter dbg = new DebugPrinter(g, 50, 60);
    dbg.print(
        "Spring-mass demo by yigal irani, drag balls or create new ones by clicking inside box");
    dbg.print("frame", numpaint);
    dbg.print("fps", 1 / timer.time_diff);

    Point top_left = point_by_vec(new Vec(-1, 1));
    g.draw3DRect(top_left.x, top_left.y, screen_dist(2), screen_dist(2), true);
    for (int i = 0; i < springs.size(); i++) {
      Spring spring = springs.get2(i);
      Point p1 = point_by_vec(balls.get2(spring.start).pos);
      Point p2 = point_by_vec(balls.get2(spring.end).pos);
      g.drawLine(p1.x, p1.y, p2.x, p2.y);
    }
    for (int i = 0; i < balls.size(); i++) {
      Ball ball = balls.get2(i);
      Point p = point_by_vec(ball.pos);
      int screen_radius = screen_dist(RADIUS);
      g.setColor(Color.blue);
      g.fillOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.setColor(Color.white);
      g.drawOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.drawString("" + i, p.x, p.y);
    }
  }
示例#19
0
  @Override
  public void paintDeterminate(Graphics g, JComponent c) {
    Insets b = progressBar.getInsets(); // area for border
    int barRectWidth = progressBar.getWidth() - b.right - b.left;
    int barRectHeight = progressBar.getHeight() - b.top - b.bottom;
    if (barRectWidth <= 0 || barRectHeight <= 0) {
      return;
    }
    // int cellLength = getCellLength();
    // int cellSpacing = getCellSpacing();
    // amount of progress to draw
    int amountFull = getAmountFull(b, barRectWidth, barRectHeight);

    // draw the cells
    if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) {
      float x = amountFull / (float) barRectWidth;
      g.setColor(getColorFromPallet(pallet, x));
      g.fillRect(b.left, b.top, amountFull, barRectHeight);
    } else { // VERTICAL
      float y = amountFull / (float) barRectHeight;
      g.setColor(getColorFromPallet(pallet, y));
      g.fillRect(b.left, barRectHeight + b.bottom - amountFull, barRectWidth, amountFull);
    }
    // Deal with possible text painting
    if (progressBar.isStringPainted()) {
      paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b);
    }
  }
示例#20
0
 public void actionPerformed(ActionEvent evt) {
   graph.setColor(Color.cyan);
   graph.fillRect(0, 0, SIZE.width, SIZE.height);
   bar.draw(graph);
   for (int i = 0; i < balls.length; i++) balls[i].draw(graph);
   repaint();
 }
示例#21
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   Color borderColorLo = AbstractLookAndFeel.getFrameColor();
   Color borderColorHi =
       ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
   if (c.getParent() instanceof JMenuBar) {
     if (model.isArmed() || model.isSelected()) {
       g.setColor(borderColorLo);
       g.drawLine(x, y, x + w - 1, y);
       g.drawLine(x, y, x, y + h - 1);
       g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
       g.setColor(borderColorHi);
       g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
       g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
     }
   } else {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(borderColorLo);
       g.drawLine(x, y, x + w - 1, y);
       g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
       g.setColor(borderColorHi);
       g.drawLine(x, y + 1, x + w - 2, y + 1);
     }
   }
 }
示例#22
0
 protected void paintComponent(Graphics g) {
   Dimension size = this.getSize();
   int x = 0;
   int y = 0;
   g.setColor(new Color((int) seq1, (int) seq2, (int) seq3));
   g.fillRect(x, y, size.width, size.height);
 }
  private void drawColorBar(Graphics g) {
    int minimum, maximum, height;

    minimum = 100;
    maximum = 500;
    height = 1;
    int finalI = 0;

    for (int i = 0; i < (maximum - minimum); i++) {
      float f = 0.75f * i / (float) (maximum - minimum);
      g.setColor(Color.getHSBColor(0.75f - f, 1.0f, 1.0f));
      g.fillRect(getWidth() - 40, height * i + 50, 20, height);
      finalI = i;
    }

    g.setColor(Color.BLACK);
    g.drawString(
        String.valueOf(this.opticalReturnPowerController.getMaxValue()),
        getWidth() - 60,
        48); // Max Value
    g.drawString(
        String.valueOf(this.opticalReturnPowerController.getMinValue()),
        getWidth() - 60,
        finalI + 63); // Min Value
  }
 public void paint(Graphics g) {
   MetalBumps usedBumps;
   if (splitPane.hasFocus()) {
     usedBumps = focusBumps;
     g.setColor(primaryControlColor);
   } else {
     usedBumps = bumps;
     g.setColor(controlColor);
   }
   Rectangle clip = g.getClipBounds();
   Insets insets = getInsets();
   g.fillRect(clip.x, clip.y, clip.width, clip.height);
   Dimension size = getSize();
   size.width -= inset * 2;
   size.height -= inset * 2;
   int drawX = inset;
   int drawY = inset;
   if (insets != null) {
     size.width -= (insets.left + insets.right);
     size.height -= (insets.top + insets.bottom);
     drawX += insets.left;
     drawY += insets.top;
   }
   usedBumps.setBumpArea(size);
   usedBumps.paintIcon(this, g, drawX, drawY);
   super.paint(g);
 }
 // Show a message over frozen image in the display
 public void showMessage(String message) {
   Graphics g = getGraphics();
   g.setColor(Color.black);
   g.fillRect(30, (getHeight() / 2) - 16, message.length() * 10, 25);
   g.setColor(Color.white);
   g.drawString(message, 40, getHeight() / 2);
 }
示例#26
0
  /**
   * Draw the LineSelection at its current location. It is the responsibility of the
   * applet/application to draw the LineSelection at the appropriate times, e.g., inside the
   * component's update() and/or paint() method. This gives maximum flexibility for double
   * buffering, etc.
   *
   * @param g The Graphics context to use for drawing.
   */
  public void draw(Graphics g) {

    if (!isVisible()) {
      return;
    }

    Color saveColor = g.getColor();
    g.setColor(color);
    if (thickness > 1) {
      double ratio = ((double) thickness) / ((double) length());
      double txdb = ratio * ((double) height) / 2.0;
      int tx = txdb > 0 ? ((int) Math.ceil(txdb)) : ((int) Math.floor(txdb));
      double tydb = -ratio * ((double) width) / 2.0;
      int ty = tydb > 0 ? ((int) Math.ceil(tydb)) : ((int) Math.floor(tydb));
      Point[] poly = new Point[4];
      for (int i = 0; i < 4; i++) poly[i] = new Point(x, y);
      poly[0].translate(tx, ty);
      poly[1].translate(-tx, -ty);
      poly[2].translate(width, height);
      poly[2].translate(-tx, -ty);
      poly[3].translate(width, height);
      poly[3].translate(tx, ty);
      Polygon polygon = new Polygon();
      for (int i = 0; i < 4; i++) polygon.addPoint(poly[i].x, poly[i].y);
      g.fillPolygon(polygon);
    } else g.drawLine(x, y, x + width, y + height);
    g.setColor(saveColor);
  } // end draw
 protected void paintText(Graphics g, JComponent com, Rectangle rect, String s) {
   JButtonLinkA bn = (JButtonLinkA) com;
   ButtonModel bnModel = bn.getModel();
   Color color = bn.getForeground();
   Object obj = null;
   if (bnModel.isEnabled()) {
     if (bnModel.isPressed()) bn.setForeground(bn.getActiveLinkColor());
     else if (bn.isLinkVisited()) bn.setForeground(bn.getVisitedLinkColor());
     else bn.setForeground(bn.getLinkColor());
   } else {
     if (bn.getDisabledLinkColor() != null) bn.setForeground(bn.getDisabledLinkColor());
   }
   super.paintText(g, com, rect, s);
   int behaviour = bn.getLinkBehavior();
   boolean drawLine = false;
   if (behaviour == JButtonLinkA.HOVER_UNDERLINE) {
     if (bnModel.isRollover()) drawLine = true;
   } else if (behaviour == JButtonLinkA.ALWAYS_UNDERLINE
       || behaviour == JButtonLinkA.SYSTEM_DEFAULT) drawLine = true;
   if (!drawLine) return;
   FontMetrics fm = g.getFontMetrics();
   int x = rect.x + getTextShiftOffset();
   int y = (rect.y + fm.getAscent() + fm.getDescent() + getTextShiftOffset()) - 1;
   if (bnModel.isEnabled()) {
     g.setColor(bn.getForeground());
     g.drawLine(x, y, (x + rect.width) - 1, y);
   } else {
     g.setColor(bn.getBackground().brighter());
     g.drawLine(x, y, (x + rect.width) - 1, y);
   }
 }
示例#28
0
    public void paint(Graphics g) {
      Dimension dim = getSize();

      g.draw3DRect(1, 1, dim.width - 3, dim.height - 3, true);
      g.setColor(Color.black);
      g.drawRect(0, 0, dim.width - 1, dim.height - 1);
    }
示例#29
0
  private void drawAxes(Graphics g) {
    g.drawLine(padding, height, width + padding, height);
    g.drawLine(padding, 0, padding, height);

    g.drawString("time", padding + width / 2, height + padding - 5);
    g.drawString("pop", 5, height / 2);
  }
 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);
   }
 }