예제 #1
0
    private void paintToImage(
        final BufferedImage img, final int x, final int y, final int width, final int height) {
      // clear the prior image
      Graphics2D imgG = (Graphics2D) img.getGraphics();
      imgG.setComposite(AlphaComposite.Clear);
      imgG.setColor(Color.black);
      imgG.fillRect(0, 0, width + blur * 2, height + blur * 2);

      final int adjX = (int) (x + blur + offsetX + (insets.left * distance));
      final int adjY = (int) (y + blur + offsetY + (insets.top * distance));
      final int adjW = (int) (width - (insets.left + insets.right) * distance);
      final int adjH = (int) (height - (insets.top + insets.bottom) * distance);

      // let the delegate paint whatever they want to be blurred
      imgG.setComposite(AlphaComposite.DstAtop);
      if (prePainter != null) prePainter.paint(imgG, adjX, adjY, adjW, adjH);
      imgG.dispose();

      // blur the prior image back into the same pixels
      imgG = (Graphics2D) img.getGraphics();
      imgG.setComposite(AlphaComposite.DstAtop);
      imgG.setRenderingHint(
          RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
      imgG.setRenderingHint(
          RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
      imgG.drawImage(img, blurOp, 0, 0);

      if (postPainter != null) postPainter.paint(imgG, adjX, adjY, adjW, adjH);
      imgG.dispose();
    }
예제 #2
0
  @Override
  public void draw(
      Graphics2D g2d,
      ComponentState componentState,
      boolean outlineMode,
      Project project,
      IDrawingObserver drawingObserver) {
    g2d.setStroke(
        ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));

    if (componentState != ComponentState.DRAGGING) {
      Composite oldComposite = g2d.getComposite();
      if (alpha < MAX_ALPHA) {
        g2d.setComposite(
            AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
      }
      g2d.setColor(color);
      g2d.fillOval(
          firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
      g2d.setComposite(oldComposite);
    }
    // Do not track any changes that follow because the whole oval has been
    // tracked so far.
    drawingObserver.stopTracking();
    g2d.setColor(
        componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
            ? SELECTION_COLOR
            : borderColor);
    g2d.drawOval(
        firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
  }
예제 #3
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);
 }
예제 #4
0
  public void paintComponent(Graphics g) {

    super.paintComponent(g);
    Composite com = ((Graphics2D) g).getComposite();
    try {
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.03f));
      for (int i = 0; i < getHeight() / getRowHeight(); i++) {
        g.setColor(Color.BLACK);
        g.fillRect(0, i * 2 * getRowHeight(), getWidth(), getRowHeight());
      }

    } finally {
      ((Graphics2D) g).setComposite(com);
    }

    // DropLocation dl = getDropLocation();
    // if (dl != null) {
    // if (dl.getChildIndex() >= 0) {
    // TreePath destPath = dl.getPath().pathByAddingChild(((MenuItemData)
    // dl.getPath().getLastPathComponent()).getItems().get(dl.getChildIndex()));
    // Rectangle pb = getUI().getPathBounds(this, destPath);
    // com = ((Graphics2D) g).getComposite();
    // try {
    // ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
    // g.fillRect(pb.x, pb.y - 5, 600, 5);
    // } finally {
    // ((Graphics2D) g).setComposite(com);
    // }
    // // getUI().getRowForPath(tree, path)
    // }
    //
    // }

  }
예제 #5
0
 static void printBorder(PrintWriter html, Border border) {
   Insets insets = border.getBorderInsets(new JToolBar());
   html.println(
       "<td>Border Insets("
           + insets.top
           + ","
           + insets.left
           + ","
           + insets.bottom
           + ","
           + insets.right
           + ")</pre></td>");
   int w = 50 + insets.left + insets.right;
   int h = 20 + insets.top + insets.bottom;
   try {
     BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
     Graphics2D g2 = img.createGraphics();
     Composite old = g2.getComposite();
     g2.setComposite(AlphaComposite.Clear);
     g2.fillRect(0, 0, w, h);
     g2.setComposite(old);
     g2.setColor(Color.RED);
     g2.fillRect(insets.left, insets.top, 49, 19);
     border.paintBorder(null, g2, 0, 0, w, h);
     g2.dispose();
     html.println("<td>" + saveImage(img) + "</td>");
   } catch (Exception e) {
     // e.printStackTrace();
     html.println("<td>NPE&nbsp;</td>");
   }
 }
예제 #6
0
  @Override
  public final void paint(Graphics g) {

    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    Composite old = g2.getComposite(); // Store non-transparent composite

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); // 40% transparency
    g2.drawRect(0, 0, getWidth() - 1, getHeight() - 1);

    Font drawFont = g2.getFont();
    g2.setFont(notificationFont);
    adaptDimensions();

    int textX = 5;
    int textY = (getHeight() / 2 + 3);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f)); // 70% transparency
    g2.drawString(message, textX, textY);

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f)); // 5% transparency
    g2.setColor(java.awt.Color.blue);
    g2.fillRect(0, 0, this.getWidth() - 1, this.getHeight() - 1);
    g2.setComposite(old);
    g2.setFont(drawFont);
  }
예제 #7
0
 static void printInsets(PrintWriter html, Insets insets) {
   html.println(
       "<td>Insets ("
           + insets.top
           + ","
           + insets.left
           + ","
           + insets.bottom
           + ","
           + insets.right
           + ")</pre></td>");
   int w = 50 + insets.left + insets.right;
   int h = 20 + insets.top + insets.bottom;
   BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
   Graphics2D g2 = img.createGraphics();
   Composite old = g2.getComposite();
   g2.setComposite(AlphaComposite.Clear);
   g2.fillRect(0, 0, w, h);
   g2.setComposite(old);
   g2.setColor(Color.BLACK);
   g2.drawRect(insets.left, insets.top, 49, 19);
   g2.setColor(Color.RED);
   g2.drawRect(0, 0, w - 1, h - 1);
   g2.dispose();
   html.println("<td>" + saveImage(img) + "</td>");
 }
    @Override
    public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
      final int iconWidth = getIconWidth();
      final int iconHeight = getIconHeight();
      if (myColor != null) {
        g.setColor(myColor);
        g.fillRect(i, j, iconWidth, iconHeight);
      } else if (myColours != null) {
        final Color top = myColours[0];
        g.setColor(top);
        g.fillRect(i, j, iconWidth, 2);

        final Color right = myColours[1];
        g.setColor(right);
        g.fillRect(i + iconWidth / 2, j + 2, iconWidth / 2, iconHeight / 2);

        final Color bottom = myColours[2];
        g.setColor(bottom);
        g.fillRect(i, j + iconHeight - 2, iconWidth, 2);

        final Color left = myColours[3];
        g.setColor(left);
        g.fillRect(i, j + 2, iconWidth / 2, iconHeight / 2);
      }

      final Composite old = ((Graphics2D) g).getComposite();
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f));
      g.setColor(Color.BLACK);
      g.drawRect(i, j, iconWidth - 1, iconHeight - 1);
      ((Graphics2D) g).setComposite(old);
    }
  @Override
  public void nextFrame(long time) {
    // TODO Auto-generated method stub

    // draw
    Graphics2D g2d = getImage().createGraphics();
    // fill with black
    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 1.0f));
    g2d.setColor(Color.BLACK);
    g2d.fillRect(0, 0, getImage().getWidth(), getImage().getHeight());

    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, thisAlpha));
    // g2d.setColor(c);

    // this.setImage(textImage);
    g2d.drawImage(textImage, 0, 0, null);

    // some hacky math here to get a hold and then fast fade
    thisAlpha = 1.5f - (float) deathTimer.percentDone() * 1.5f;
    // thisAlpha = thisAlpha - .005f;
    // System.out.println(deathTimer.timeElapsed());

    // thisAlpha = 1.0f;

    if (thisAlpha <= 0) {
      kill();
    } else if (thisAlpha > 1.0f) {
      thisAlpha = 1.0f;
    }

    if (deathTimer.isDone()) {
      kill();
    }
  }
예제 #10
0
 static void printFont(PrintWriter html, Font font) {
   String style = "";
   if (font.isBold() && font.isItalic()) {
     style = "Bold & Italic";
   } else if (font.isBold()) {
     style = "Bold";
   } else if (font.isItalic()) {
     style = "Italic";
   }
   html.println("<td>Font: " + font.getFamily() + " " + font.getSize() + " " + style + "</td>");
   int w = 300, h = 30;
   BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
   Graphics2D g2 = img.createGraphics();
   Composite old = g2.getComposite();
   g2.setComposite(AlphaComposite.Clear);
   g2.fillRect(0, 0, w, h);
   g2.setComposite(old);
   g2.setColor(Color.BLACK);
   g2.setFont(font);
   g2.setRenderingHint(
       RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
   g2.drawString("The quick brown fox jumps over the lazy dog.", 5, 20);
   g2.dispose();
   html.println("<td>" + saveImage(img) + "</td>");
 }
예제 #11
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());
   }
 }
예제 #12
0
  /**
   * Draws the band.
   *
   * @param g2 the graphics device.
   * @param plotArea the plot area.
   * @param dataArea the data area.
   * @param x the x-coordinate.
   * @param y the y-coordinate.
   */
  public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
      IntervalMarker marker = (IntervalMarker) iterator.next();
      double start = Math.max(marker.getStartValue(), this.axis.getRange().getLowerBound());
      double end = Math.min(marker.getEndValue(), this.axis.getRange().getUpperBound());
      double s = this.axis.valueToJava2D(start, dataArea, RectangleEdge.BOTTOM);
      double e = this.axis.valueToJava2D(end, dataArea, RectangleEdge.BOTTOM);
      Rectangle2D r =
          new Rectangle2D.Double(
              s, y + this.topOuterGap, e - s, h - this.topOuterGap - this.bottomOuterGap);

      Composite originalComposite = g2.getComposite();
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha()));
      g2.setPaint(marker.getPaint());
      g2.fill(r);
      g2.setPaint(marker.getOutlinePaint());
      g2.draw(r);
      g2.setComposite(originalComposite);

      g2.setPaint(Color.black);
      drawStringInRect(g2, r, this.font, marker.getLabel());
    }
  }
예제 #13
0
  public void draw(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;

    int hGap = 0;
    int y1 = this.y1;

    if (hPosition) {
      hGap = hGap + grpage.hPosition;
      gapH = hGap;
    }

    y1 = y1 + hGap;

    Color oldC = g2d.getColor();
    Stroke oldStroke = g2d.getStroke();

    g2d.setColor(Color.BLUE);
    Composite compositeOld = g2d.getComposite();

    if (selected) {
      g2d.setStroke(new BasicStroke(2.0f));
    }
    g2d.drawRect(0, y1, width, height);

    g2d.setComposite(composite);
    g2d.setPaint(Color.BLUE);
    g2d.fill(new Rectangle(0, y1, width, height));

    g2d.setComposite(compositeOld);
    g2d.setColor(oldC);
    g2d.setStroke(oldStroke);

    yRelative = y1;
    grpage.hPosition = y1 + height;
  }
  @Override
  public void paintComponent(Graphics graphics) {
    super.paintComponent(graphics);
    //		 painting only if approved
    if (show) {
      // init graphics
      Graphics2D g = (Graphics2D) graphics;

      int pixWidth = getWidth() - 2 * MARGIN;
      int pixHeight = getHeight() - 2 * MARGIN;

      // painting background
      g.drawImage(this.image, MARGIN, MARGIN, pixWidth, pixHeight, Color.WHITE, null);

      // painting transparent class overlay
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaLevel));
      g.drawImage(this.classImage, MARGIN, MARGIN, pixWidth, pixHeight, Color.WHITE, null);
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
      // painting points
      drawPoints(g);

      // painting Legend
      drawLegend(graphics, this.dataTable, colorColumn);

      // paint Tooltip
      drawToolTip((Graphics2D) graphics);
    }
  }
예제 #15
0
    public void paint(Graphics g) {
      Dimension size = getSize();
      Color colors[];
      if (isEnabled()) {
        if (getModel().isArmed() && getModel().isPressed()) {
          colors = BaseLookAndFeel.getTheme().getPressedColors();
        } else if (getModel().isRollover()) {
          colors = BaseLookAndFeel.getTheme().getRolloverColors();
        } else {
          colors = BaseLookAndFeel.getTheme().getButtonColors();
        }
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
      Utilities.fillHorGradient(g, colors, 0, 0, size.width, size.height);

      boolean inverse = ColorHelper.getGrayValue(colors) < 128;

      Icon icon = inverse ? BaseIcons.getComboBoxInverseIcon() : BaseIcons.getComboBoxIcon();
      int x = (size.width - icon.getIconWidth()) / 2;
      int y = (size.height - icon.getIconHeight()) / 2;

      Graphics2D g2D = (Graphics2D) g;
      Composite savedComposite = g2D.getComposite();
      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
      if (getModel().isPressed() && getModel().isArmed()) {
        icon.paintIcon(this, g, x + 2, y + 1);
      } else {
        icon.paintIcon(this, g, x + 1, y);
      }
      g2D.setComposite(savedComposite);
      paintBorder(g2D);
    }
예제 #16
0
  /* (non-Javadoc)
   * @see maptool.model.drawing.Drawable#draw(java.awt.Graphics2D, maptool.model.drawing.Pen)
   */
  public void draw(Graphics2D g, Pen pen, int translateX, int translateY) {
    if (pen == null) {
      pen = Pen.DEFAULT;
    }

    Stroke oldStroke = g.getStroke();
    g.setStroke(new BasicStroke(pen.getThickness(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    Composite oldComposite = g.getComposite();
    if (pen.isEraser()) {
      g.setComposite(AlphaComposite.Clear);
    }

    if (pen.getBackgroundMode() == Pen.MODE_SOLID) {
      Color bgColor = new Color(pen.getBackgroundColor());
      g.setColor(bgColor);
      drawBackground(g, translateX, translateY);
    }

    if (pen.getForegroundMode() == Pen.MODE_SOLID) {
      Color color = new Color(pen.getColor());
      g.setColor(color);
      draw(g, translateX, translateY);
    }

    g.setComposite(oldComposite);
    g.setStroke(oldStroke);
  }
예제 #17
0
  // Scaling relative to the center of the screen
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (bufferImage == null) {
      bufferImage = createImage(getWidth(), getHeight());
      bufferg = (Graphics2D) bufferImage.getGraphics();

      updateAffineTransform();
      preSize = getSize();
    }
    bufferg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    bufferg.setTransform(new AffineTransform());
    bufferg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
    bufferg.setColor(Color.WHITE);
    bufferg.fillRect(0, 0, getWidth(), getHeight());

    bufferg.setTransform(affineTransform);

    Graphics2D g2d = bufferg;

    if (ORIPA.doc.hasModel) {
      g2d.setStroke(Config.STROKE_CUT);
      if (Globals.modelDispMode == Constants.ModelDispMode.FILL_ALPHA) {
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f));
      }
      drawModel(g2d);
      g.drawImage(bufferImage, 0, 0, this);
    }
  }
예제 #18
0
 public void paint(Graphics g) {
   try {
     Graphics2D g2d = (Graphics2D) g;
     g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
     g2d.setColor(Color.BLACK);
     g2d.fill(new Rectangle2D.Float(0, 0, getWidth(), getHeight()));
     drawWorld(g2d, Main.world);
     g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
     g2d.setColor(Color.BLUE);
     g2d.drawRect(
         Main.brush.getR().x,
         Main.brush.getR().y,
         Main.brush.getR().width,
         Main.brush.getR().height);
     g2d.setColor(Color.DARK_GRAY);
     g2d.fill(new Rectangle2D.Float(getWidth() - 200, 0, 200, getHeight()));
     g2d.setColor(Color.LIGHT_GRAY);
     g2d.fill(new Rectangle2D.Float(getWidth() - 200, 0, 5, getHeight()));
     g2d.drawImage(Assets.getTileImage(Main.brush.type), getWidth() - 170, 60, 32, 32, null);
     for (int i = 0; i < Main.infoBoxes.size(); i++) {
       drawInfoBox(g2d, Main.infoBoxes.get(i));
     }
     for (int i = 0; i < Main.buttons.size(); i++) {
       drawButton(g2d, Main.buttons.get(i));
     }
     g2d.drawImage(Assets.overlay, 0, 0, getWidth(), getHeight(), null);
   } catch (Exception ex) {
     // ex.printStackTrace();
   }
 }
예제 #19
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (((JToolBar) c).isFloatable()) {
     Graphics2D g2D = (Graphics2D) g;
     Composite savedComposite = g2D.getComposite();
     AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
     g2D.setComposite(alpha);
     if (((JToolBar) c).getOrientation() == HORIZONTAL) {
       if (!JTattooUtilities.isLeftToRight(c)) {
         x += w - 15;
       }
       g.setColor(Color.white);
       g.drawLine(x + 3, y + 4, x + 3, h - 5);
       g.drawLine(x + 6, y + 3, x + 6, h - 4);
       g.drawLine(x + 9, y + 4, x + 9, h - 5);
       g.setColor(shadow);
       g.drawLine(x + 4, y + 4, x + 4, h - 5);
       g.drawLine(x + 7, y + 3, x + 7, h - 4);
       g.drawLine(x + 10, y + 4, x + 10, h - 5);
     } else {
       // vertical
       g.setColor(Color.white);
       g.drawLine(x + 3, y + 3, w - 4, y + 3);
       g.drawLine(x + 3, y + 6, w - 4, y + 6);
       g.drawLine(x + 3, y + 9, w - 4, y + 9);
       g.setColor(shadow);
       g.drawLine(x + 3, y + 4, w - 4, y + 4);
       g.drawLine(x + 3, y + 7, w - 4, y + 7);
       g.drawLine(x + 3, y + 10, w - 4, y + 10);
     }
     g2D.setComposite(savedComposite);
   }
 }
예제 #20
0
  private void drawShape(Shuttle shuttle) {
    Graphics2D g = shuttle.g;
    Shape oldclip = shuttle.g.getClip();
    g.setClip(shuttle.clip);
    Composite oldcomposite = g.getComposite();
    if (shuttle.opacity != 1f) {
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, shuttle.opacity));
    }

    AffineTransform oldtr = g.getTransform();
    g.setTransform(shuttle.transform);

    Stroke oldStroke = g.getStroke();
    Stroke newStroke =
        new BasicStroke(shuttle.strokeWidth, shuttle.linecap.stroke(), shuttle.linejoin.stroke());
    g.setStroke(newStroke);

    if (shuttle.fill != null) {
      g.setPaint(shuttle.fill);
      g.fill(shuttle.shape);
    }
    if (shuttle.stroke != null) {
      g.setPaint(shuttle.stroke);
      g.draw(shuttle.shape);
    }
    g.setClip(oldclip);
    g.setStroke(oldStroke);
    g.setTransform(oldtr);
    g.setComposite(oldcomposite);
  }
예제 #21
0
 @Override
 public void render(Graphics f) {
   try {
     if (isVisible()) {
       // setup graphics
       Graphics2D gfx = (Graphics2D) f;
       gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
       // redo backdrop
       gfx.setComposite(AlphaComposite.Clear);
       gfx.fillRect(0, 0, width, height);
       gfx.setComposite(AlphaComposite.Src);
       // render marker
       if (host.getTarget() != null) {
         // draw marker
         gfx.setStroke(new BasicStroke(2));
         // pick by range
         float range = (float) host.getNearWeaponRange();
         float distance = host.getLocation().distance(host.getTarget().getLocation());
         if (range < distance) {
           gfx.setColor(Color.orange);
         } else {
           gfx.setColor(Color.blue);
         }
         // draw
         gfx.drawRect(5, 5, width - 10, height - 10);
       }
     }
   } catch (Exception e) {
     System.out.println("Error rendering sight marker");
   }
 }
예제 #22
0
  /** renders this JComponent */
  @Override
  public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    // paint page
    super.paintComponent(g);
    // set label color
    if (this.getBackground().getBlue()
            + this.getBackground().getGreen()
            + this.getBackground().getRed()
        > 400) {
      g.setColor(Color.DARK_GRAY);
    } else {
      g.setColor(Color.LIGHT_GRAY);
    }

    // paint label at correct position
    if (fullview) {
      int xpos =
          (int)
              (this.getWidth() * 0.5
                  - g.getFontMetrics().getStringBounds(this.getName(), g).getCenterX());
      g.drawString(this.getName(), xpos, getHeight() / 2);
      g.drawString(this.getName(), xpos, getHeight() / 4);
      g.drawString(this.getName(), xpos, getHeight() * 3 / 4);

      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.33F));
      int imageX = (int) (this.getWidth() / 2 - IMAGE_WIDTH / 2 * Page.zoom);
      int imageWidth = (int) (IMAGE_WIDTH * Page.zoom);
      g.drawImage(this.getImage(), imageX, getHeight() / 2 + 5, imageWidth, imageWidth, null);
      g.drawImage(this.getImage(), imageX, getHeight() / 4 + 5, imageWidth, imageWidth, null);
      g.drawImage(this.getImage(), imageX, getHeight() * 3 / 4 + 5, imageWidth, imageWidth, null);
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
    }
  }
예제 #23
0
  /** Paints selection for the specified <code>component</code>. */
  public static void paintSelectionDecoration(
      @NotNull RadComponent component, Graphics g, boolean focused) {
    if (component.isSelected()) {
      if (focused) {
        g.setColor(PlatformColors.BLUE);
      } else {
        g.setColor(Color.GRAY);
      }
      final Point[] points = getPoints(component.getWidth(), component.getHeight());
      for (final Point point : points) {
        g.fillRect(point.x - R, point.y - R, 2 * R + 1, 2 * R + 1);
      }
    } else if (component.getWidth() < FormEditingUtil.EMPTY_COMPONENT_SIZE
        || component.getHeight() < FormEditingUtil.EMPTY_COMPONENT_SIZE) {
      Graphics2D g2d = (Graphics2D) g;
      Composite oldComposite = g2d.getComposite();
      Stroke oldStroke = g2d.getStroke();
      Color oldColor = g2d.getColor();

      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f));
      g2d.setStroke(new BasicStroke(0.7f));
      g2d.setColor(Color.black);
      g2d.drawRect(
          0,
          0,
          Math.max(component.getWidth(), FormEditingUtil.EMPTY_COMPONENT_SIZE),
          Math.max(component.getHeight(), FormEditingUtil.EMPTY_COMPONENT_SIZE));

      g2d.setComposite(oldComposite);
      g2d.setStroke(oldStroke);
      g2d.setColor(oldColor);
    }
  }
예제 #24
0
 protected void drawImageMosaic(Graphics2D g2) {
   // Break the image up into tiles. Draw each
   //   tile with its own transparency, allowing
   //   the background to show through to varying
   //   degrees.
   int side = 36;
   int width = mImage.getWidth();
   int height = mImage.getHeight();
   for (int y = 0; y < height; y += side) {
     for (int x = 0; x < width; x += side) {
       // Calculate an appropriate transparency value.
       float xBias = (float) x / (float) width;
       float yBias = (float) y / (float) height;
       float alpha = 1.0f - Math.abs(xBias - yBias);
       g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
       // Draw the subimage.
       int w = Math.min(side, width - x);
       int h = Math.min(side, height - y);
       BufferedImage tile = mImage.getSubimage(x, y, w, h);
       g2.drawImage(tile, x, y, null);
     }
   }
   // Reset the composite.
   g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
 }
예제 #25
0
 public void drawTransparent(Graphics g, int x, int y, float opacity) {
   BufferedImage tranny = getCurrentImage();
   Graphics2D g2d = ((Graphics2D) g);
   Composite c = g2d.getComposite();
   g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
   g2d.drawImage(tranny, x, y, null);
   g2d.setComposite(c);
 }
 protected void paint(Graphics g, Rectangle rect, JTextComponent c) {
   Graphics2D g2d = (Graphics2D) g;
   Composite originalComposite = g2d.getComposite();
   g2d.setComposite(alphaComposite);
   g2d.setPaint(color);
   g2d.fill(rect);
   g2d.setComposite(originalComposite);
 }
예제 #27
0
 /**
  * Returns an image that can be used by effects as a temp image.
  *
  * @return The scratch image used for temporary operations
  */
 public static BufferedImage getScratchImage() {
   Graphics2D g = (Graphics2D) scratchImage.getGraphics();
   g.setComposite(AlphaComposite.Clear);
   g.fillRect(0, 0, GlyphPage.MAX_GLYPH_SIZE, GlyphPage.MAX_GLYPH_SIZE);
   g.setComposite(AlphaComposite.SrcOver);
   g.setColor(java.awt.Color.white);
   return scratchImage;
 }
예제 #28
0
 public void paint(Graphics g) {
   Graphics2D g2d = (Graphics2D) g;
   Composite oldComp = g2d.getComposite();
   Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
   g2d.setComposite(alphaComp);
   super.paint(g2d);
   g2d.setComposite(oldComp);
 }
예제 #29
0
 private void paintBackground(WmsRequest request, Graphics2D g) {
   g.setColor(request.getBackgroundColor());
   g.setBackground(request.getBackgroundColor());
   if (request.isTransparent()) g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
   else g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.0f));
   g.fillRect(0, 0, 100, 100);
   g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
 }
예제 #30
0
파일: Trail.java 프로젝트: havess/Tails
  public void render(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setComposite(makeTransparent(alpha));

    g.setColor(color);
    g.fillRect(x, y, width, height);

    g2d.setComposite(makeTransparent(1));
  }